forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
76 lines (71 loc) · 1.8 KB
/
index.js
File metadata and controls
76 lines (71 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function testCase(load, done) {
load("two", 2, function() {
var sync = true;
load("one", 1, function() {
expect(sync).toBe(false);
load("three", 3, function() {
var sync = true;
load("two", 2, function() {
expect(sync).toBe(true);
done();
});
Promise.resolve().then(function() {}).then(function() {}).then(function() {
sync = false;
});
});
});
Promise.resolve().then(function() {
sync = false;
});
});
}
it("should be able to use expressions in import", function(done) {
function load(name, expected, callback) {
import("./dir/" + name + '.js')
.then((result) => {expect(result).toEqual({
default: expected,
[Symbol.toStringTag]: "Module"
}); callback()})
.catch((err) => {done(err)});
}
testCase(load, done);
});
it("should be able to use expressions in lazy-once import", function(done) {
function load(name, expected, callback) {
import(/* webpackMode: "lazy-once" */ "./dir/" + name + '.js')
.then((result) => {expect(result).toEqual({
default: expected,
[Symbol.toStringTag]: "Module"
}); callback()})
.catch((err) => {done(err)});
}
testCase(load, done);
});
it("should be able to use expressions in import", function(done) {
function load(name, expected, callback) {
import("./dir2/" + name).then((result) => {
expect(result).toEqual({
default: expected,
[Symbol.toStringTag]: "Module"
});
callback();
}).catch((err) => {
done(err);
});
}
testCase(load, done);
});
it("should convert to function in node", function() {
expect((typeof __webpack_require__.e)).toBe("function");
})
it("should be able to use import", function(done) {
import("./two").then((two) => {
expect(two).toEqual({
default: 2,
[Symbol.toStringTag]: "Module"
});
done();
}).catch(function(err) {
done(err);
});
});