Add unit tests for chunk sort

This commit is contained in:
Jan Nicklas 2015-11-23 14:08:25 +01:00 committed by Jan Nicklas
parent e813b0576a
commit 2b726e8031
1 changed files with 46 additions and 0 deletions

View File

@ -663,4 +663,50 @@ describe('HtmlWebpackPlugin', function() {
}, ["HtmlWebpackPlugin Error: Child compilation failed:\nEntry module not found: Error: Cannot resolve 'file' or 'directory'"], null, done, true);
});
it('should short the chunks', function(done) {
testHtmlPlugin({
entry: {
util: path.join(__dirname, 'fixtures/util.js'),
index: path.join(__dirname, 'fixtures/index.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]_bundle.js'
},
plugins: [
new CommonsChunkPlugin({
name: 'common',
filename: "common_bundle.js",
}),
new HtmlWebpackPlugin({
chunksSortMode: 'auto'
})
]
}, [
/<script src="common_bundle.js">.+<script src="util_bundle.js">.+<script src="index_bundle.js">/], null, done);
});
it('should short the chunks with custom (alphabetical) order', function(done) {
testHtmlPlugin({
entry: {
b: path.join(__dirname, 'fixtures/index.js'),
c: path.join(__dirname, 'fixtures/util.js'),
a: path.join(__dirname, 'fixtures/index.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
chunksSortMode: function(a, b) {
if(a.name < b.name) {return 1;}
if(a.name > b.name) {return -1;}
return 0;
}
})
]
}, [/<script src="a_bundle.js">.+<script src="b_bundle.js">.+<script src="c_bundle.js">/], null, done);
});
});