-
-
Notifications
You must be signed in to change notification settings - Fork 591
/
version-multi-args.test.js
78 lines (61 loc) · 3.53 KB
/
version-multi-args.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const { run } = require('../utils/test-utils');
const pkgJSON = require('../../packages/webpack-cli/package.json');
describe('version flag with multiple arguments', () => {
it('does not output version with help command', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['version', 'help'], false);
expect(exitCode).toBe(0);
expect(stdout).not.toContain(pkgJSON.version);
expect(stdout).toContain('The build tool for modern web applications');
expect(stderr).toHaveLength(0);
});
it('does not output version with help dashed', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['version', '--help'], false);
expect(exitCode).toBe(0);
expect(stdout).not.toContain(pkgJSON.version);
expect(stdout).toContain('The build tool for modern web applications');
expect(stderr).toHaveLength(0);
});
it('throws error if invalid command is passed with version command', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['version', 'abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
it('throws error if invalid option is passed with version command', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['version', '--abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
it('throws error if invalid command is passed with --version flag', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['--version', 'abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
it('throws error if invalid option is passed with --version flag', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['--version', '--abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
it('throws error if invalid command is passed with -v alias', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['-v', 'abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
it('throws error if invalid option is passed with -v alias', () => {
const { stdout, stderr, exitCode } = run(__dirname, ['-v', '--abc'], false);
expect(exitCode).toBe(2);
expect(stdout).not.toContain(pkgJSON.version);
expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`);
expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments');
});
});