2017-05-31 11:56:34 +08:00
|
|
|
require("should");
|
|
|
|
const sinon = require("sinon");
|
2017-06-05 16:59:48 +08:00
|
|
|
const chunkLoadingSpy = sinon.spy(__webpack_require__, "e");
|
2017-05-31 11:56:34 +08:00
|
|
|
|
|
|
|
it("should not have duplicate chunks in blocks", function(done) {
|
|
|
|
// This split point should contain: a
|
|
|
|
require.ensure([], function(require) {
|
|
|
|
require("./a").should.be.eql("a");
|
2017-06-05 16:59:48 +08:00
|
|
|
}, "a");
|
2017-05-31 11:56:34 +08:00
|
|
|
|
|
|
|
// This split point should contain: a and b - we use CommonsChunksPlugin to
|
|
|
|
// have it only contain b and make chunk a be an async dependency.
|
|
|
|
require.ensure([], function(require) {
|
|
|
|
require("./a").should.be.eql("a");
|
|
|
|
require("./b").should.be.eql("b");
|
2017-06-05 16:59:48 +08:00
|
|
|
}, "a+b");
|
2017-05-31 11:56:34 +08:00
|
|
|
|
|
|
|
// This split point should contain: a, b and c - we use CommonsChunksPlugin to
|
|
|
|
// have it only contain c and make chunks a and a+b be async dependencies.
|
|
|
|
require.ensure([], function(require) {
|
|
|
|
require("./a").should.be.eql("a");
|
|
|
|
require("./b").should.be.eql("b");
|
|
|
|
require("./c").should.be.eql("c");
|
2017-06-05 16:59:48 +08:00
|
|
|
}, "a+b+c");
|
2017-05-31 11:56:34 +08:00
|
|
|
|
|
|
|
// Each of the require.ensures above should end up resolving chunks:
|
|
|
|
// - a
|
|
|
|
// - a, a+b
|
|
|
|
// - a, a+b, a+b+c
|
|
|
|
chunkLoadingSpy.callCount.should.be.eql(6);
|
2018-01-20 00:06:59 +08:00
|
|
|
chunkLoadingSpy.args.should.be.eql([["a"], ["a"], ["a+b~a+b+c" /* == b */], ["a"], ["a+b~a+b+c" /* == b */], ["a+b+c"]]);
|
2017-05-31 11:56:34 +08:00
|
|
|
done();
|
|
|
|
});
|