Skip to content

Commit f7ec953

Browse files
authored
tests: optimization-flags test updates for webpack-rc.2 (#1846)
1 parent 0f13ab5 commit f7ec953

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

test/core-flags/optimization-flags.test.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ describe('optimization config related flag', () => {
1212
if (flag.name.includes('split-chunks')) {
1313
property = flag.name.split('optimization-split-chunks-')[1];
1414
}
15-
const propName = hyphenToUpperCase(property);
15+
16+
let propName = hyphenToUpperCase(property);
17+
if (flag.name.includes('-reset')) {
18+
propName = propName.split('Reset')[0];
19+
}
1620

1721
if (flag.type === Boolean) {
1822
it(`should config --${flag.name} correctly`, () => {
@@ -21,20 +25,24 @@ describe('optimization config related flag', () => {
2125
if (flag.name === 'optimization-split-chunks') {
2226
expect(stdout).toContain(`chunks: 'async'`);
2327
expect(stdout).toContain(`minChunks: 1`);
28+
} else if (flag.name.includes('reset')) {
29+
expect(stdout).toContain(`${propName}: []`);
2430
} else {
2531
expect(stdout).toContain(`${propName}: true`);
2632
}
2733
});
2834

29-
it(`should config --no-${flag.name} correctly`, () => {
30-
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
31-
expect(stderr).toBeFalsy();
32-
if (flag.name === 'optimization-split-chunks') {
33-
expect(stdout).toContain('splitChunks: false');
34-
} else {
35-
expect(stdout).toContain(`${propName}: false`);
36-
}
37-
});
35+
if (!flag.name.includes('reset')) {
36+
it(`should config --no-${flag.name} correctly`, () => {
37+
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
38+
expect(stderr).toBeFalsy();
39+
if (flag.name === 'optimization-split-chunks') {
40+
expect(stdout).toContain('splitChunks: false');
41+
} else {
42+
expect(stdout).toContain(`${propName}: false`);
43+
}
44+
});
45+
}
3846
}
3947

4048
// ignoring optimization-runtime-* and split-chunks-fallback-* flags because WebpackClITestPlugin logs [Object]
@@ -52,6 +60,8 @@ describe('optimization config related flag', () => {
5260
} else if (flag.name === 'optimization-used-exports') {
5361
stdout = run(__dirname, ['--optimization-used-exports', 'global']).stdout;
5462
expect(stdout).toContain(`usedExports: 'global'`);
63+
} else if (flag.name === 'optimization-split-chunks-default-size-types') {
64+
expect(stdout).toContain(`defaultSizeTypes: [Array]`);
5565
} else {
5666
expect(stdout).toContain(`${propName}: 'named'`);
5767
}

0 commit comments

Comments
 (0)