|
| 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