Skip to content
Permalink
Browse files
add more test cases
  • Loading branch information
sokra committed May 28, 2018
1 parent 7708471 commit 023d4ca945e830f34a68bdd9962af056a5a62696
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
@@ -0,0 +1,61 @@

it("should be possible to import json data async", function() {
return Promise.all([
import("../data/a.json"),
import("../data/b.json"),
import("../data/c.json"),
import("../data/d.json"),
import("../data/e.json"),
import("../data/f.json"),
import("../data/g.json")
]).then(([a, b, c, d, e, f, g]) => {
expect(a).toEqual({
default: null,
[Symbol.toStringTag]: "Module"
});
expect(b).toEqual({
default: 123,
[Symbol.toStringTag]: "Module"
});
expect(c).toEqual({
0: 1,
1: 2,
2: 3,
3: 4,
default: [1, 2, 3, 4],
[Symbol.toStringTag]: "Module"
});
expect(d).toEqual({
default: {},
[Symbol.toStringTag]: "Module"
});
expect(e).toEqual({
aa: 1,
bb: 2,
1: "x",
default: {
aa: 1,
bb: 2,
"1": "x"
},
[Symbol.toStringTag]: "Module"
});
expect(f).toEqual({
named: "named",
default: {
named: "named",
"default": "default",
__esModule: true
},
[Symbol.toStringTag]: "Module"
});
expect(g).toEqual({
named: {},
default: {
named: {}
},
[Symbol.toStringTag]: "Module"
});
expect(g.named).toBe(g.default.named);
});
});
@@ -0,0 +1,4 @@
{
"default": "default",
"named": "named"
}
@@ -40,11 +40,11 @@ function contextHarmony(name) {

function contextMixed(name) {
return Promise.all([
import(`./dir-mixed/${name}.js`),
import(/* webpackMode: "lazy-once" */`./dir-mixed?1/${name}.js`),
import(/* webpackMode: "eager" */`./dir-mixed?2/${name}.js`)
import(`./dir-mixed/${name}`),
import(/* webpackMode: "lazy-once" */`./dir-mixed?1/${name}`),
import(/* webpackMode: "eager" */`./dir-mixed?2/${name}`)
]).then(function(results) {
return import(/* webpackMode: "weak" */`./dir-mixed/${name}.js`).then(function(r) {
return import(/* webpackMode: "weak" */`./dir-mixed/${name}`).then(function(r) {
results.push(r);
return results;
});
@@ -80,6 +80,7 @@ it("should receive a namespace object when importing mixed content via context",
promiseTest(contextMixed("one"), { default: { named: "named", default: "default" }, [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("two"), { default: { __esModule: true, named: "named", default: "default" }, [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("three"), { named: "named", default: "default", [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("null"), { default: null, [Symbol.toStringTag]: "Module" })
promiseTest(contextMixed("null"), { default: null, [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("json.json"), { named: "named", default: { named: "named", default: "default" }, [Symbol.toStringTag]: "Module" })
]);
});
@@ -0,0 +1,4 @@
{
"default": "default",
"named": "named"
}
@@ -80,6 +80,7 @@ it("should receive a namespace object when importing mixed content via context",
promiseTest(contextMixed("one"), { named: "named", default: { named: "named", default: "default" }, [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("two"), { __esModule: true, named: "named", default: "default" }),
promiseTest(contextMixed("three"), { named: "named", default: "default", [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("null"), { default: null, [Symbol.toStringTag]: "Module" })
promiseTest(contextMixed("null"), { default: null, [Symbol.toStringTag]: "Module" }),
promiseTest(contextMixed("json.json"), { named: "named", default: { named: "named", default: "default" }, [Symbol.toStringTag]: "Module" })
]);
});

0 comments on commit 023d4ca

Please sign in to comment.