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

LibJS: Convert Proxy tests

This commit is contained in:
Matthew Olsson 2020-07-03 22:43:08 -07:00 committed by Andreas Kling
parent b86faeaeef
commit 449a1cf3a2
14 changed files with 820 additions and 815 deletions

View file

@ -1,30 +1,31 @@
load("test-common.js");
test("constructs properly", () => {
expect(() => {
new Proxy({}, {});
}).not.toThrow();
});
try {
new Proxy({}, {});
assertThrowsError(() => {
test("constructor argument count", () => {
expect(() => {
new Proxy();
}, {
error: TypeError,
message: "Proxy constructor requires at least two arguments",
});
}).toThrowWithMessage(TypeError, "Proxy constructor requires at least two arguments");
assertThrowsError(() => {
Proxy();
}, {
error: TypeError,
message: "Proxy must be called with the 'new' operator",
});
expect(() => {
new Proxy({});
}).toThrowWithMessage(TypeError, "Proxy constructor requires at least two arguments");
});
assertThrowsError(() => {
test("constructor requires objects", () => {
expect(() => {
new Proxy(1, {});
}, {
error: TypeError,
message: "Expected target argument of Proxy constructor to be object, got 1",
});
}).toThrowWithMessage(TypeError, "Expected target argument of Proxy constructor to be object, got 1");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(() => {
new Proxy({}, 1);
}).toThrowWithMessage(TypeError, "Expected handler argument of Proxy constructor to be object, got 1");
});
test("constructor must be invoked with 'new'", () => {
expect(() => {
Proxy({}, {});
}).toThrowWithMessage(TypeError, "Proxy must be called with the 'new' operator");
});