1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +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,74 +1,82 @@
test("length is 3", () => {
expect(Reflect.defineProperty).toHaveLength(3);
expect(Reflect.defineProperty).toHaveLength(3);
});
describe("errors", () => {
test("target must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.defineProperty(value);
}).toThrowWithMessage(TypeError, "First argument of Reflect.defineProperty() must be an object");
});
test("target must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.defineProperty(value);
}).toThrowWithMessage(
TypeError,
"First argument of Reflect.defineProperty() must be an object"
);
});
});
test("descriptor must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.defineProperty({}, "foo", value);
}).toThrowWithMessage(TypeError, "Descriptor argument is not an object");
});
test("descriptor must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.defineProperty({}, "foo", value);
}).toThrowWithMessage(TypeError, "Descriptor argument is not an object");
});
});
});
describe("normal behavior", () => {
test("initial value and non-writable", () => {
var o = {};
test("initial value and non-writable", () => {
var o = {};
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, writable: false })).toBeTrue();
expect(o.foo).toBe(1);
o.foo = 2;
expect(o.foo).toBe(1);
});
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, writable: false })).toBeTrue();
expect(o.foo).toBe(1);
o.foo = 2;
expect(o.foo).toBe(1);
});
test("initial value and writable", () => {
var o = {};
test("initial value and writable", () => {
var o = {};
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, writable: true })).toBeTrue();
expect(o.foo).toBe(1);
o.foo = 2;
expect(o.foo).toBe(2);
});
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, writable: true })).toBeTrue();
expect(o.foo).toBe(1);
o.foo = 2;
expect(o.foo).toBe(2);
});
test("can redefine value of configurable, writable property", () => {
var o = {};
test("can redefine value of configurable, writable property", () => {
var o = {};
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: true })).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
expect(o.foo).toBe(2);
});
expect(o.foo).toBeUndefined();
expect(
Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: true })
).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
expect(o.foo).toBe(2);
});
test("can redefine value of configurable, non-writable property", () => {
var o = {};
test("can redefine value of configurable, non-writable property", () => {
var o = {};
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: false })).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
expect(o.foo).toBe(2);
});
expect(o.foo).toBeUndefined();
expect(
Reflect.defineProperty(o, "foo", { value: 1, configurable: true, writable: false })
).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeTrue();
expect(o.foo).toBe(2);
});
test("cannot redefine value of non-configurable, non-writable property", () => {
var o = {};
test("cannot redefine value of non-configurable, non-writable property", () => {
var o = {};
expect(o.foo).toBeUndefined();
expect(Reflect.defineProperty(o, "foo", { value: 1, configurable: false, writable: false })).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeFalse();
expect(o.foo).toBe(1);
});
expect(o.foo).toBeUndefined();
expect(
Reflect.defineProperty(o, "foo", { value: 1, configurable: false, writable: false })
).toBeTrue();
expect(o.foo).toBe(1);
expect(Reflect.defineProperty(o, "foo", { value: 2 })).toBeFalse();
expect(o.foo).toBe(1);
});
});