webpack/test/configCases/parsing/system.import/index.js

39 lines
739 B
JavaScript
Raw Normal View History

it("should answer typeof System correctly", () => {
2018-06-26 16:59:23 +08:00
if(__SYSTEM__) {
expect((typeof System)).toBe("object");
2018-06-26 16:59:23 +08:00
} else {
expect((typeof System)).toBe("undefined");
}
});
it("should answer typeof System.import correctly", () => {
2018-06-26 16:59:23 +08:00
if(__SYSTEM__) {
expect((typeof System.import)).toBe("function");
} else {
expect(() => {
typeof System.import;
}).toThrowError();
}
});
it("should be able to use System.import()", done => {
try {
System.import("./module").then(mod => {
2018-06-26 16:59:23 +08:00
if(__SYSTEM__) {
2018-07-11 17:13:47 +08:00
expect(mod).toEqual(nsObj({
default: "ok"
}));
done();
2018-06-26 16:59:23 +08:00
} else {
done(new Error("System.import should not be parsed"));
}
});
} catch(e) {
2018-06-26 16:59:23 +08:00
if(__SYSTEM__) {
done(e);
2018-06-26 16:59:23 +08:00
} else {
done();
}
}
});