1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:28:11 +00:00

LibJS: Implement the import assertions proposal

The hard part of parsing them in import statements and calls was already
done so this is just removing some check which threw before on
assertions. And filtering the assertions based on the result of a new
host hook.
This commit is contained in:
davidot 2022-01-27 02:44:03 +01:00 committed by Linus Groh
parent e0e4ead2c8
commit f568939568
11 changed files with 270 additions and 83 deletions

View file

@ -9,14 +9,14 @@ function validTestModule(filename) {
}
}
function expectModulePassed(filename) {
function expectModulePassed(filename, options = undefined) {
validTestModule(filename);
let moduleLoaded = false;
let moduleResult = null;
let thrownError = null;
import(filename)
import(filename, options)
.then(result => {
moduleLoaded = true;
moduleResult = result;
@ -130,6 +130,11 @@ describe("testing behavior", () => {
test("expectModulePassed works", () => {
expectModulePassed("./single-const-export.mjs");
});
test("can call expectModulePassed with options", () => {
expectModulePassed("./single-const-export.mjs", { key: "value" });
expectModulePassed("./single-const-export.mjs", { key1: "value1", key2: "value2" });
});
});
describe("in- and exports", () => {
@ -173,6 +178,10 @@ describe("in- and exports", () => {
"Invalid or ambiguous export entry 'default'"
);
});
test("can import with (useless) assertions", () => {
expectModulePassed("./import-with-assertions.mjs");
});
});
describe("loops", () => {