forked from webpack/webpack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
help-flags.test.js
30 lines (25 loc) · 1.22 KB
/
help-flags.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const { run } = require('../utils/test-utils');
const helpHeader = 'The build tool for modern web applications';
describe('commands help', () => {
it('throws error for invalid flag with --help flag', () => {
const { stderr } = run(__dirname, ['--help', '--my-flag'], false);
expect(stderr).toContain(`You provided an invalid option '--my-flag'`);
});
it('throws error for invalid flag with help command', () => {
const { stderr } = run(__dirname, ['help', '--my-flag'], false);
expect(stderr).toContain(`You provided an invalid option '--my-flag'`);
});
it('shows flag help with valid flag', () => {
const { stdout, stderr } = run(__dirname, ['--help', '--merge'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack -m, --merge');
expect(stderr).toHaveLength(0);
});
it('gives precedence to earlier flag in case of multiple flags', () => {
const { stdout, stderr } = run(__dirname, ['--help', '--entry', '--merge'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack --entry <path to entry file>');
expect(stderr).toHaveLength(0);
});
});