webpack/test/browsertest/node_modules/library2/lib/main.js

58 lines
1.5 KiB
JavaScript

// Chunked File library
describe("library2", function() {
var tickExtra, tickEmpty, tickMerged;
var extraValue, testValue;
before(function(done) {
var asnycOk = false, asnycOk2 = false;
var sameTick1 = true;
require.ensure("./extra", function(require) {
asnycOk = true;
tickExtra = sameTick1;
var sameTick2 = true;
require.ensure([], function(require) {
asnycOk2 = true;
extraValue = require("./extra");
tickEmpty = sameTick2;
require.ensure(["./test.js"], function(require) {
tickMerged = sameTick2;
testValue = require("./test.js");
done();
});
});
sameTick2 = false;
});
sameTick1 = false;
});
it("should load stuff with require.ensure asynchron", function() {
should.exist(tickExtra);
tickExtra.should.be.eql(false);
});
it("should load not include stuff from parent, remove empty chunks and apply a post loader", function() {
should.exist(tickEmpty);
tickEmpty.should.be.eql(true);
extraValue.should.be.eql("Lib2 extra2 with post loader");
});
it("should merge chunks if maxChunks specified", function() {
should.exist(tickEmpty);
tickEmpty.should.be.eql(true);
testValue.should.be.eql("test module");
});
it("should load require.amd from options", function() {
require.amd.should.have.property("fromOptions").be.eql(true);
});
it("should run empty AMD require", function() {
var emptyRequire = false;
require([], function() {
emptyRequire = true;
});
emptyRequire.should.be.eql(true);
});
});
exports.ok = true;