From 6ea52bcf3d7cc6e9f9175874858c7f53597ead28 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 16 Jul 2023 10:23:39 -0400 Subject: [PATCH] Rename fixture to readFixture and add a comment block describe how the fixtures / scenarios work --- tests/assertions.ts | 4 ++-- tests/utils.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/assertions.ts b/tests/assertions.ts index f1461ed4..94783f4b 100644 --- a/tests/assertions.ts +++ b/tests/assertions.ts @@ -3,7 +3,7 @@ import fs from 'node:fs/promises'; import path from 'node:path'; import { expect } from 'vitest'; -import { fixture, packageJsonAt } from './utils.js'; +import { packageJsonAt, readFixture } from './utils.js'; interface AssertGeneratedOptions { projectRoot: string; @@ -88,7 +88,7 @@ export async function matchesFixture( } let sourceContents = (await fs.readFile(testFilePath)).toString(); - let fixtureContents = await fixture(fixtureFile, { scenario }); + let fixtureContents = await readFixture(fixtureFile, { scenario }); /** * We trim because whether or not the source or fixture has diff --git a/tests/utils.ts b/tests/utils.ts index 9c0341d3..69b32aab 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -13,7 +13,15 @@ const fixturesPath = path.join(__dirname, 'fixtures'); export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'] as const; -export async function fixture( +/** + * Returns the contents of a file from the "tests/fixtures" directory. + * The "tests/fixtures" directory contains sub-directories, "scenarios". + * This is we can have different sets of fixtures, depending on what we're testing. + * + * The default scenario is "default", and represents the the file contents when we provide + * no arguments to the blueprint + */ +export async function readFixture( /** * Which file within in the fixture-set / scenario to read */