Skip to content

Commit 7faadc8

Browse files
committed
Wrap tests in describe()
1 parent acfc0bd commit 7faadc8

File tree

1 file changed

+59
-57
lines changed

1 file changed

+59
-57
lines changed

test/cli.js

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -58,61 +58,63 @@ function run(...cliArgs) {
5858
return wrapper;
5959
}
6060

61-
it('should output version', () =>
62-
run('-v')
63-
.stdout(version)
64-
);
65-
66-
it('should output help', () =>
67-
run('-h')
68-
.stdout(/Usage:/)
69-
);
70-
71-
it('should read content from stdin if no file specified', () =>
72-
run()
73-
.stdin(fixtureContent('css/style.css'))
74-
.stderr(fixtureContent('css/style.validate-result')
75-
.replace(/^#.+\n/, '# <stdin>\n')
76-
)
77-
);
78-
79-
it('should read from file', () =>
80-
run(path.relative(process.cwd(), fixturePath('css/style.css')))
81-
.stderr(fixtureContent('css/style.validate-result'))
82-
);
83-
84-
it('should error when wrong reporter', () =>
85-
run(path.relative(process.cwd(), fixturePath('css/style.css')), '--reporter', 'bad-value')
86-
.stderr('Wrong value for reporter: bad-value')
87-
);
88-
89-
it('should error when file doesn\'t exist', () =>
90-
run('not/exists.css')
91-
.stderr('ERROR! No such file or directory: not/exists.css')
92-
);
93-
94-
describe('custom reporter', () => {
95-
const cwd = path.resolve('fixtures/custom-reporter');
96-
const tests = {
97-
// module
98-
'ESM module': 'custom-reporter.js',
99-
'commonjs module': 'custom-reporter.cjs',
100-
101-
// package
102-
'commonjs package': 'commonjs',
103-
'commonjs package (path to dir)': 'commonjs/lib',
104-
'commonjs package (full path)': 'commonjs/lib/index.js',
105-
'esm package': 'esm',
106-
'esm package (full path)': 'esm/lib/index.js',
107-
'dual package': 'dual',
108-
'dual package (full path)': 'dual/lib/index.js',
109-
'dual package (full path to cjs)': 'dual/lib/index.cjs'
110-
};
111-
112-
for (const [title, reporter] of Object.entries(tests)) {
113-
it(title, () =>
114-
run({ cwd }, 'style.css', '-r', reporter)
115-
.stderr('OK')
116-
);
117-
}
61+
describe('cli', () => {
62+
it('should output version', () =>
63+
run('-v')
64+
.stdout(version)
65+
);
66+
67+
it('should output help', () =>
68+
run('-h')
69+
.stdout(/Usage:/)
70+
);
71+
72+
it('should read content from stdin if no file specified', () =>
73+
run()
74+
.stdin(fixtureContent('css/style.css'))
75+
.stderr(fixtureContent('css/style.validate-result')
76+
.replace(/^#.+\n/, '# <stdin>\n')
77+
)
78+
);
79+
80+
it('should read from file', () =>
81+
run(path.relative(process.cwd(), fixturePath('css/style.css')))
82+
.stderr(fixtureContent('css/style.validate-result'))
83+
);
84+
85+
it('should error when wrong reporter', () =>
86+
run(path.relative(process.cwd(), fixturePath('css/style.css')), '--reporter', 'bad-value')
87+
.stderr('Wrong value for reporter: bad-value')
88+
);
89+
90+
it('should error when file doesn\'t exist', () =>
91+
run('not/exists.css')
92+
.stderr('ERROR! No such file or directory: not/exists.css')
93+
);
94+
95+
describe('custom reporter', () => {
96+
const cwd = path.resolve('fixtures/custom-reporter');
97+
const tests = {
98+
// module
99+
'ESM module': 'custom-reporter.js',
100+
'commonjs module': 'custom-reporter.cjs',
101+
102+
// package
103+
'commonjs package': 'commonjs',
104+
'commonjs package (path to dir)': 'commonjs/lib',
105+
'commonjs package (full path)': 'commonjs/lib/index.js',
106+
'esm package': 'esm',
107+
'esm package (full path)': 'esm/lib/index.js',
108+
'dual package': 'dual',
109+
'dual package (full path)': 'dual/lib/index.js',
110+
'dual package (full path to cjs)': 'dual/lib/index.cjs'
111+
};
112+
113+
for (const [title, reporter] of Object.entries(tests)) {
114+
it(title, () =>
115+
run({ cwd }, 'style.css', '-r', reporter)
116+
.stderr('OK')
117+
);
118+
}
119+
});
118120
});

0 commit comments

Comments
 (0)