Skip to content

Commit

Permalink
[Tests] reorganize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 7, 2024
1 parent 41a8ad6 commit 9e280e5
Show file tree
Hide file tree
Showing 19 changed files with 4 additions and 20 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 4 additions & 20 deletions test/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,15 @@ import stripColors from 'strip-color';

const fixtureDir = join(import.meta.dirname, 'fixtures');

const fixtures = readdirSync(fixtureDir);
const valid = readdirSync(join(fixtureDir, 'valid'));
const invalid = readdirSync(join(fixtureDir, 'invalid'));

test('nvmrc', async (t) => {
const valid = [
'basic',
'basic-comments',
'basic-with-comment',
'basic-with-npm',
];

const invalid = [
'basic-invalid',
'invalid',
'only-comments',
'pre-normalized',
'duplicate-pairs',
];

t.deepEqual(fixtures.sort(), valid.concat(invalid).sort(), 'all fixtures are accounted for');

const bin = join(import.meta.dirname, '../nvmrc.mjs');

for (const fixture of valid) {
t.test(`fixture ${fixture}`, (st) => {
const cwd = join(fixtureDir, fixture);
const cwd = join(fixtureDir, 'valid', fixture);

const { status, stdout } = spawnSync(`${bin}`, { cwd });

Expand All @@ -52,7 +36,7 @@ test('nvmrc', async (t) => {

for (const fixture of invalid) {
t.test(`fixture ${fixture}`, (st) => {
const cwd = join(fixtureDir, fixture);
const cwd = join(fixtureDir, 'invalid', fixture);

const { status, stderr } = spawnSync(`${bin}`, { cwd });

Expand Down

0 comments on commit 9e280e5

Please sign in to comment.