webpack/test/browsertest/node_modules/library1/index.js

30 lines
892 B
JavaScript
Raw Normal View History

// Single File library
var loadTimelibrary1 = typeof window.library1 === "undefined"
describe("library1", function() {
it("should load library1 only once", function() {
2018-01-24 23:00:43 +08:00
expect(loadTimelibrary1).toBe(true);
2012-10-29 05:44:32 +08:00
});
2015-07-07 06:11:13 +08:00
2012-10-29 05:44:32 +08:00
it("should load a component", function() {
2018-01-24 23:00:43 +08:00
expect(require("./lib/component")).toBe("lib1 component");
2012-10-29 05:44:32 +08:00
});
2015-07-07 06:11:13 +08:00
2012-10-29 05:44:32 +08:00
it("should load async submodules with require.ensure even if single == true", function(done) {
var sameTick = true;
require.ensure(["submodule1", "submodule2"], function(require) {
2018-01-24 23:00:43 +08:00
expect(sameTick).toBe(true);
expect(require("submodule1")).toBe("submodule1");
expect(require("submodule2")).toBe("submodule2");
expect(require("submodule3")()).toBe("submodule3");
2012-10-29 05:44:32 +08:00
require.ensure([], function(require) {
2018-01-24 23:00:43 +08:00
expect(sameTick).toBe(true);
2012-10-29 05:44:32 +08:00
done();
});
});
2015-07-07 06:11:13 +08:00
setImmediate(function() {
sameTick = false;
});
2012-03-10 20:11:23 +08:00
});
});
2018-01-24 23:00:43 +08:00
module.exports = true;