webpack/test/configCases/externals/async-externals/index.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import value from "promise-external";
2020-08-07 23:34:36 +08:00
import value2 from "module-promise-external";
import value3 from "object-promise-external";
import request from "import-external";
2024-08-05 16:47:45 +08:00
import request2 from "module-import-external";
2020-08-07 23:34:36 +08:00
import "./module.mjs";
it("should allow async externals", () => {
expect(value).toBe(42);
2020-08-07 23:34:36 +08:00
expect(value2).toBe(42);
expect(value3).toEqual({ default: 42, named: true });
expect(request).toBe("/hello/world.js");
2024-08-05 16:47:45 +08:00
expect(request2).toBe("/hello/world.js");
});
it("should allow to catch errors of async externals", () => {
return expect(() => import("failing-promise-external")).rejects.toEqual(
expect.objectContaining({
message: "external reject"
})
);
});
2020-08-05 01:37:16 +08:00
it("should allow dynamic import promise externals", () => {
return import("promise-external").then(module => {
2020-08-07 23:34:36 +08:00
expect(module).toMatchObject({ default: 42 });
});
});
it("should allow dynamic import promise externals that are modules", () => {
return import("module-promise-external").then(module => {
expect(module).toMatchObject({ default: 42, named: true });
});
});
it("should allow dynamic import promise externals that are objects", () => {
return import("object-promise-external").then(module => {
expect(module).toMatchObject({
default: { default: 42, named: true },
named: true
});
2020-08-05 01:37:16 +08:00
});
});