Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

Commit fb310ed

Browse files
committed
Plugin options
1 parent ebea366 commit fb310ed

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

test/plugin-init-test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import test from "ava";
2+
import InlineChunkManifestHtmlWebpackPlugin from "../src/";
3+
import ChunkManifestPlugin from "chunk-manifest-webpack-plugin";
4+
5+
test("has defaults", t => {
6+
const expected = {
7+
manifestFilename: "manifest.json",
8+
manifestVariable: "webpackManifest"
9+
};
10+
const plugin = new InlineChunkManifestHtmlWebpackPlugin();
11+
t.is(plugin.manifestFilename, expected.manifestFilename);
12+
t.is(plugin.manifestVariable, expected.manifestVariable);
13+
t.is(plugin.chunkManifestVariable, "webpackChunkManifest");
14+
t.is(plugin.dropAsset, false);
15+
16+
t.is(plugin.plugins.length, 1);
17+
18+
const manifestPlugin = plugin.plugins[0];
19+
t.true(manifestPlugin instanceof ChunkManifestPlugin);
20+
t.is(manifestPlugin.manifestFilename, expected.manifestFilename);
21+
t.is(manifestPlugin.manifestVariable, expected.manifestVariable);
22+
});
23+
24+
test("override drop asset", t => {
25+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({ dropAsset: true });
26+
t.is(plugin.dropAsset, true);
27+
});
28+
29+
test("override manifest filename", t => {
30+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
31+
filename: "another.file"
32+
});
33+
const manifestPlugin = plugin.plugins[0];
34+
35+
t.is(plugin.manifestFilename, "another.file");
36+
t.is(manifestPlugin.manifestFilename, "another.file");
37+
});
38+
39+
test("override manifest variable", t => {
40+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
41+
manifestVariable: "a-variable"
42+
});
43+
const manifestPlugin = plugin.plugins[0];
44+
45+
t.is(plugin.manifestVariable, "a-variable");
46+
t.is(manifestPlugin.manifestVariable, "a-variable");
47+
});
48+
49+
test("override chunk manifest variable", t => {
50+
const plugin = new InlineChunkManifestHtmlWebpackPlugin({
51+
chunkManifestVariable: "another-variable"
52+
});
53+
54+
t.is(plugin.chunkManifestVariable, "another-variable");
55+
});

0 commit comments

Comments
 (0)