Skip to content

Commit

Permalink
est: Add test for test option in banner plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffin143 committed Apr 19, 2020
1 parent 8915dba commit 2026b46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/configCases/plugins/banner-plugin/index.js
Expand Up @@ -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");
4 changes: 4 additions & 0 deletions test/configCases/plugins/banner-plugin/webpack.config.js
Expand Up @@ -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}`
}),
Expand Down

0 comments on commit 2026b46

Please sign in to comment.