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

feat(webpack-cli): allow multiple entry files #1619

Merged
merged 10 commits into from
Jun 17, 2020
Prev Previous commit
Next Next commit
tests: update arg-parser tests
  • Loading branch information
snitin315 committed Jun 9, 2020
commit 624549af8c439e72e5772748850829a72a7eff1e
19 changes: 18 additions & 1 deletion packages/webpack-cli/__tests__/arg-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ const basicOptions = [
},
description: 'custom type flag',
},
{
name: 'multi-flag',
usage: '--multi-flag <value>',
type: String,
multiple: true,
description: 'multi flag',
},
];

const helpAndVersionOptions = basicOptions.slice(0);
Expand Down Expand Up @@ -163,6 +170,16 @@ describe('arg-parser', () => {
expect(warnMock.mock.calls.length).toEqual(0);
});

it('handles multiple same args', () => {
const res = argParser(basicOptions, ['--multi-flag', 'a.js', '--multi-flag', 'b.js'], true);
expect(res.unknownArgs.length).toEqual(0);
expect(res.opts).toEqual({
multiFlag: ['a.js', 'b.js'],
stringFlagWithDefault: 'default-value',
});
expect(warnMock.mock.calls.length).toEqual(0);
});

it('handles additional node args from argv', () => {
const res = argParser(basicOptions, ['node', 'index.js', '--bool-flag', '--string-flag', 'val'], false);
expect(res.unknownArgs.length).toEqual(0);
Expand Down Expand Up @@ -210,7 +227,7 @@ describe('arg-parser', () => {
it('parses webpack args', () => {
const res = argParser(core, ['--entry', 'test.js', '--hot', '-o', './dist/'], true);
expect(res.unknownArgs.length).toEqual(0);
expect(res.opts.entry).toEqual('test.js');
expect(res.opts.entry).toEqual(['test.js']);
expect(res.opts.hot).toBeTruthy();
expect(res.opts.output).toEqual('./dist/');
expect(warnMock.mock.calls.length).toEqual(0);
Expand Down