Skip to content

Commit 833e825

Browse files
test: validation (#111)
1 parent 1627c6e commit 833e825

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/__snapshots__/validation.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,10 @@ exports[`validation 16`] = `
171171
options.deleteOriginalAssets should be boolean
172172
"
173173
`;
174+
175+
exports[`validation 17`] = `
176+
"Compression Plugin Invalid Options
177+
178+
options should NOT have additional properties
179+
"
180+
`;

test/validation.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ it('validation', () => {
1010
new CompressionPlugin({ test: 'foo' });
1111
}).not.toThrow();
1212

13+
expect(() => {
14+
new CompressionPlugin({ test: [/foo/] });
15+
}).not.toThrow();
16+
1317
expect(() => {
1418
new CompressionPlugin({ test: [/foo/, /bar/] });
1519
}).not.toThrow();
@@ -34,10 +38,18 @@ it('validation', () => {
3438
new CompressionPlugin({ test: [/foo/, 'foo', true] });
3539
}).toThrowErrorMatchingSnapshot();
3640

41+
expect(() => {
42+
new CompressionPlugin({ include: /foo/ });
43+
}).not.toThrow();
44+
3745
expect(() => {
3846
new CompressionPlugin({ include: 'foo' });
3947
}).not.toThrow();
4048

49+
expect(() => {
50+
new CompressionPlugin({ include: [/foo/] });
51+
}).not.toThrow();
52+
4153
expect(() => {
4254
new CompressionPlugin({ include: [/foo/, /bar/] });
4355
}).not.toThrow();
@@ -62,10 +74,18 @@ it('validation', () => {
6274
new CompressionPlugin({ include: [/foo/, 'foo', true] });
6375
}).toThrowErrorMatchingSnapshot();
6476

77+
expect(() => {
78+
new CompressionPlugin({ exclude: /foo/ });
79+
}).not.toThrow();
80+
6581
expect(() => {
6682
new CompressionPlugin({ exclude: 'foo' });
6783
}).not.toThrow();
6884

85+
expect(() => {
86+
new CompressionPlugin({ include: [/foo/] });
87+
}).not.toThrow();
88+
6989
expect(() => {
7090
new CompressionPlugin({ exclude: [/foo/, /bar/] });
7191
}).not.toThrow();
@@ -173,5 +193,9 @@ it('validation', () => {
173193
expect(() => {
174194
new CompressionPlugin({ deleteOriginalAssets: 'true' });
175195
}).toThrowErrorMatchingSnapshot();
196+
197+
expect(() => {
198+
new CompressionPlugin({ unknown: true });
199+
}).toThrowErrorMatchingSnapshot();
176200
/* eslint-enable no-new */
177201
});

0 commit comments

Comments
 (0)