From 8915dbacc17ada62d9d6d42e4f40b32ca133b9c5 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Sun, 19 Apr 2020 14:31:31 +0530 Subject: [PATCH 1/2] test: Add test for include option in banner plugin --- test/configCases/plugins/banner-plugin/index.js | 4 +++- test/configCases/plugins/banner-plugin/webpack.config.js | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/configCases/plugins/banner-plugin/index.js b/test/configCases/plugins/banner-plugin/index.js index 69d83ba559a..f8c2a83c7b5 100644 --- a/test/configCases/plugins/banner-plugin/index.js +++ b/test/configCases/plugins/banner-plugin/index.js @@ -13,11 +13,13 @@ it("should contain banner in bundle0 chunk", () => { expect(source).toMatch( "/*!\n * trim trailing whitespace\n *\n * no trailing whitespace\n */" ); + expect(source).not.toMatch(new RegExp("^/*! A test value in single file */$")); }); it("should not contain banner in vendors chunk", () => { const source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8"); - expect(source).not.toMatch("A test value"); + expect(source).not.toMatch("/*! A test value */"); + expect(source).toMatch("/*! A test value in single file */"); }); if (Math.random() < 0) require("./test.js"); diff --git a/test/configCases/plugins/banner-plugin/webpack.config.js b/test/configCases/plugins/banner-plugin/webpack.config.js index da65d83f952..583f5063e4c 100644 --- a/test/configCases/plugins/banner-plugin/webpack.config.js +++ b/test/configCases/plugins/banner-plugin/webpack.config.js @@ -18,6 +18,10 @@ module.exports = { banner: "A test value", exclude: ["vendors.js"] }), + new webpack.BannerPlugin({ + banner: "A test value in single file", + include: ["vendors.js"] + }), new webpack.BannerPlugin({ banner: ({ chunk }) => `multiline\nbanner\n${chunk.name}` }), From 2026b467415af82a4e96bc60989d5a8c555ccc16 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Sun, 19 Apr 2020 19:54:49 +0530 Subject: [PATCH 2/2] est: Add test for test option in banner plugin --- test/configCases/plugins/banner-plugin/index.js | 2 ++ test/configCases/plugins/banner-plugin/webpack.config.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/test/configCases/plugins/banner-plugin/index.js b/test/configCases/plugins/banner-plugin/index.js index f8c2a83c7b5..e25486c1af1 100644 --- a/test/configCases/plugins/banner-plugin/index.js +++ b/test/configCases/plugins/banner-plugin/index.js @@ -14,12 +14,14 @@ it("should contain banner in bundle0 chunk", () => { "/*!\n * trim trailing whitespace\n *\n * no trailing whitespace\n */" ); expect(source).not.toMatch(new RegExp("^/*! A test value in single file */$")); + expect(source).not.toMatch(new RegExp("^/*! Match test file */$")); }); it("should not contain banner in vendors chunk", () => { const source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8"); expect(source).not.toMatch("/*! A test value */"); expect(source).toMatch("/*! A test value in single file */"); + expect(source).toMatch("/*! Match test file */"); }); if (Math.random() < 0) require("./test.js"); diff --git a/test/configCases/plugins/banner-plugin/webpack.config.js b/test/configCases/plugins/banner-plugin/webpack.config.js index 583f5063e4c..e99cae3eded 100644 --- a/test/configCases/plugins/banner-plugin/webpack.config.js +++ b/test/configCases/plugins/banner-plugin/webpack.config.js @@ -22,6 +22,10 @@ module.exports = { banner: "A test value in single file", include: ["vendors.js"] }), + new webpack.BannerPlugin({ + banner: "Match test file", + test: /vendors\.js$/ + }), new webpack.BannerPlugin({ banner: ({ chunk }) => `multiline\nbanner\n${chunk.name}` }),