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

Libraries: Move to Userland/Libraries/

This commit is contained in:
Andreas Kling 2021-01-12 12:17:30 +01:00
parent dc28c07fa5
commit 13d7c09125
1857 changed files with 266 additions and 274 deletions

View file

@ -1,66 +0,0 @@
test("length is 2", () => {
expect(Reflect.deleteProperty).toHaveLength(2);
});
describe("errors", () => {
test("target must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.deleteProperty(value);
}).toThrowWithMessage(
TypeError,
"First argument of Reflect.deleteProperty() must be an object"
);
});
});
});
describe("normal behavior", () => {
test("deleting non-existent property", () => {
expect(Reflect.deleteProperty({})).toBeTrue();
expect(Reflect.deleteProperty({}, "foo")).toBeTrue();
});
test("deleting existent property", () => {
var o = { foo: 1 };
expect(o.foo).toBe(1);
expect(Reflect.deleteProperty(o, "foo")).toBeTrue();
expect(o.foo).toBeUndefined();
expect(Reflect.deleteProperty(o, "foo")).toBeTrue();
expect(o.foo).toBeUndefined();
});
test("deleting existent, configurable, non-writable property", () => {
var o = {};
Object.defineProperty(o, "foo", { value: 1, configurable: true, writable: false });
expect(Reflect.deleteProperty(o, "foo")).toBeTrue();
expect(o.foo).toBeUndefined();
});
test("deleting existent, non-configurable, writable property", () => {
var o = {};
Object.defineProperty(o, "foo", { value: 1, configurable: false, writable: true });
expect(Reflect.deleteProperty(o, "foo")).toBeFalse();
expect(o.foo).toBe(1);
});
test("deleting existent, non-configurable, non-writable property", () => {
var o = {};
Object.defineProperty(o, "foo", { value: 1, configurable: false, writable: false });
expect(Reflect.deleteProperty(o, "foo")).toBeFalse();
expect(o.foo).toBe(1);
});
test("deleting array index", () => {
var a = [1, 2, 3];
expect(a).toHaveLength(3);
expect(a[0]).toBe(1);
expect(a[1]).toBe(2);
expect(a[2]).toBe(3);
expect(Reflect.deleteProperty(a, 1)).toBeTrue();
expect(a).toHaveLength(3);
expect(a[0]).toBe(1);
expect(a[1]).toBeUndefined();
expect(a[2]).toBe(3);
});
});