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

test: validation unknown option #111

Merged
merged 1 commit into from Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/__snapshots__/validation.test.js.snap
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
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 */
});