Skip to content

Commit

Permalink
test: validation (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Sep 5, 2018
1 parent 1627c6e commit 833e825
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/__snapshots__/validation.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ exports[`validation 16`] = `
options.deleteOriginalAssets should be boolean
"
`;

exports[`validation 17`] = `
"Compression Plugin Invalid Options
options should NOT have additional properties
"
`;
24 changes: 24 additions & 0 deletions test/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ it('validation', () => {
new CompressionPlugin({ test: 'foo' });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ test: [/foo/] });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ test: [/foo/, /bar/] });
}).not.toThrow();
Expand All @@ -34,10 +38,18 @@ it('validation', () => {
new CompressionPlugin({ test: [/foo/, 'foo', true] });
}).toThrowErrorMatchingSnapshot();

expect(() => {
new CompressionPlugin({ include: /foo/ });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ include: 'foo' });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ include: [/foo/] });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ include: [/foo/, /bar/] });
}).not.toThrow();
Expand All @@ -62,10 +74,18 @@ it('validation', () => {
new CompressionPlugin({ include: [/foo/, 'foo', true] });
}).toThrowErrorMatchingSnapshot();

expect(() => {
new CompressionPlugin({ exclude: /foo/ });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ exclude: 'foo' });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ include: [/foo/] });
}).not.toThrow();

expect(() => {
new CompressionPlugin({ exclude: [/foo/, /bar/] });
}).not.toThrow();
Expand Down Expand Up @@ -173,5 +193,9 @@ it('validation', () => {
expect(() => {
new CompressionPlugin({ deleteOriginalAssets: 'true' });
}).toThrowErrorMatchingSnapshot();

expect(() => {
new CompressionPlugin({ unknown: true });
}).toThrowErrorMatchingSnapshot();
/* eslint-enable no-new */
});

0 comments on commit 833e825

Please sign in to comment.