From 247d96111f2533b078fc2da576b27039877c9b19 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 5 Sep 2018 13:01:36 +0300 Subject: [PATCH] test: validation --- test/__snapshots__/validation.test.js.snap | 7 +++++++ test/validation.test.js | 24 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/__snapshots__/validation.test.js.snap b/test/__snapshots__/validation.test.js.snap index d10cdf1..fd1b9eb 100644 --- a/test/__snapshots__/validation.test.js.snap +++ b/test/__snapshots__/validation.test.js.snap @@ -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 +" +`; diff --git a/test/validation.test.js b/test/validation.test.js index c16b1e9..c7bdf18 100644 --- a/test/validation.test.js +++ b/test/validation.test.js @@ -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(); @@ -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(); @@ -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(); @@ -173,5 +193,9 @@ it('validation', () => { expect(() => { new CompressionPlugin({ deleteOriginalAssets: 'true' }); }).toThrowErrorMatchingSnapshot(); + + expect(() => { + new CompressionPlugin({ unknown: true }); + }).toThrowErrorMatchingSnapshot(); /* eslint-enable no-new */ });