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

test-js: Use prettier and format all files

This commit is contained in:
Matthew Olsson 2020-07-05 09:27:00 -07:00 committed by Andreas Kling
parent e532888242
commit 6d58c48c2f
248 changed files with 8291 additions and 7725 deletions

View file

@ -1,56 +1,58 @@
describe("[[Delete]] trap normal behavior", () => {
test("forwarding when not defined in handler", () => {
expect(delete (new Proxy({}, { deleteProperty: undefined })).foo).toBeTrue();
expect(delete (new Proxy({}, { deleteProperty: null })).foo).toBeTrue();
expect(delete (new Proxy({}, {})).foo).toBeTrue();
test("forwarding when not defined in handler", () => {
expect(delete new Proxy({}, { deleteProperty: undefined }).foo).toBeTrue();
expect(delete new Proxy({}, { deleteProperty: null }).foo).toBeTrue();
expect(delete new Proxy({}, {}).foo).toBeTrue();
});
test("correct arguments supplied to trap", () => {
let o = {};
let p = new Proxy(o, {
deleteProperty(target, property) {
expect(target).toBe(o);
expect(property).toBe("foo");
return true;
},
});
test("correct arguments supplied to trap", () => {
let o = {};
let p = new Proxy(o, {
deleteProperty(target, property) {
expect(target).toBe(o);
expect(property).toBe("foo");
return true;
}
});
delete p.foo;
});
delete p.foo;
test("conditional deletion", () => {
o = { foo: 1, bar: 2 };
p = new Proxy(o, {
deleteProperty(target, property) {
if (property === "foo") {
delete target[property];
return true;
}
return false;
},
});
test("conditional deletion", () => {
o = { foo: 1, bar: 2 };
p = new Proxy(o, {
deleteProperty(target, property) {
if (property === "foo") {
delete target[property];
return true;
}
return false;
}
});
expect(delete p.foo).toBeTrue();
expect(delete p.bar).toBeFalse();
expect(delete p.foo).toBeTrue();
expect(delete p.bar).toBeFalse();
expect(o.foo).toBe(undefined);
expect(o.bar).toBe(2);
});
expect(o.foo).toBeUndefined();
expect(o.bar).toBe(2);
});
});
describe("[[Delete]] invariants", () => {
test("cannot report a non-configurable own property as deleted", () => {
let o = {};
Object.defineProperty(o, "foo", { configurable: false });
let p = new Proxy(o, {
deleteProperty() {
return true;
},
});
expect(() => {
delete p.foo;
}).toThrowWithMessage(TypeError, "Proxy handler's deleteProperty trap violates invariant: cannot report a non-configurable own property of the target as deleted");
test("cannot report a non-configurable own property as deleted", () => {
let o = {};
Object.defineProperty(o, "foo", { configurable: false });
let p = new Proxy(o, {
deleteProperty() {
return true;
},
});
expect(() => {
delete p.foo;
}).toThrowWithMessage(
TypeError,
"Proxy handler's deleteProperty trap violates invariant: cannot report a non-configurable own property of the target as deleted"
);
});
});