Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor cli.test.js #5266

Merged
merged 1 commit into from Apr 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/__tests__/cli.test.js
Expand Up @@ -8,7 +8,7 @@ const cli = require('../cli');
const pkg = require('../../package.json');
const replaceBackslashes = require('../testUtils/replaceBackslashes');

const fixturesPath = replaceBackslashes(path.join(__dirname, 'fixtures'));
const fixturesPath = (...elems) => replaceBackslashes(path.join(__dirname, 'fixtures', ...elems));
const { buildCLI } = cli;

jest.mock('get-stdin');
Expand Down Expand Up @@ -203,8 +203,8 @@ describe('CLI', () => {
await cli([
'--print-config',
'--config',
`${fixturesPath}/config-color-no-invalid-hex.json`,
`${fixturesPath}/invalid-hex.css`,
fixturesPath('config-color-no-invalid-hex.json'),
fixturesPath('invalid-hex.css'),
]);

expect(process.exitCode).toBeUndefined();
Expand All @@ -227,8 +227,8 @@ describe('CLI', () => {
await cli([
'--report-needless-disables',
'--config',
replaceBackslashes(path.join(fixturesPath, 'config-block-no-empty.json')),
replaceBackslashes(path.join(fixturesPath, 'empty-block-with-disables.css')),
fixturesPath('config-block-no-empty.json'),
fixturesPath('empty-block-with-disables.css'),
]);

expect(process.exitCode).toBe(2);
Expand All @@ -242,8 +242,8 @@ describe('CLI', () => {
it('reports disallowed disables', async () => {
await cli([
'--config',
replaceBackslashes(path.join(fixturesPath, 'config-block-no-empty-report-disables.json')),
replaceBackslashes(path.join(fixturesPath, 'empty-block-with-relevant-disable.css')),
fixturesPath('config-block-no-empty-report-disables.json'),
fixturesPath('empty-block-with-relevant-disable.css'),
]);

expect(process.exitCode).toBe(2);
Expand All @@ -258,8 +258,8 @@ describe('CLI', () => {
await cli([
'--report-descriptionless-disables',
'--config',
replaceBackslashes(path.join(fixturesPath, 'config-block-no-empty.json')),
replaceBackslashes(path.join(fixturesPath, 'empty-block-with-relevant-disable.css')),
fixturesPath('config-block-no-empty.json'),
fixturesPath('empty-block-with-relevant-disable.css'),
]);

expect(process.exitCode).toBe(2);
Expand All @@ -271,7 +271,7 @@ describe('CLI', () => {
});

it('--stdin', async () => {
await cli(['--stdin', '--config', `${fixturesPath}/config-no-empty-source.json`]);
await cli(['--stdin', '--config', fixturesPath('config-no-empty-source.json')]);

expect(process.exitCode).toBe(2);

Expand All @@ -285,8 +285,8 @@ describe('CLI', () => {
it('exits with non zero on unfound module in config', async () => {
await cli([
'--config',
replaceBackslashes(path.join(fixturesPath, 'config-require-unknown.js')),
replaceBackslashes(path.join(fixturesPath, 'empty-block-with-disables.css')),
fixturesPath('config-require-unknown.js'),
fixturesPath('empty-block-with-disables.css'),
]);

expect(process.exitCode).toEqual(1);
Expand Down