1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 12:12: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,69 +1,72 @@
test("length is 2", () => {
expect(Reflect.construct).toHaveLength(2);
expect(Reflect.construct).toHaveLength(2);
});
describe("errors", () => {
test("target must be a function", () => {
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
expect(() => {
Reflect.construct(value);
}).toThrowWithMessage(TypeError, "First argument of Reflect.construct() must be a function");
});
test("target must be a function", () => {
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
expect(() => {
Reflect.construct(value);
}).toThrowWithMessage(TypeError, "First argument of Reflect.construct() must be a function");
});
});
test("arguments list must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.construct(() => {}, value);
}).toThrowWithMessage(TypeError, "Arguments list must be an object");
});
test("arguments list must be an object", () => {
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
expect(() => {
Reflect.construct(() => {}, value);
}).toThrowWithMessage(TypeError, "Arguments list must be an object");
});
});
test("new target must be a function", () => {
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
expect(() => {
Reflect.construct(() => {}, [], value);
}).toThrowWithMessage(TypeError, "Optional third argument of Reflect.construct() must be a constructor");
});
test("new target must be a function", () => {
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
expect(() => {
Reflect.construct(() => {}, [], value);
}).toThrowWithMessage(
TypeError,
"Optional third argument of Reflect.construct() must be a constructor"
);
});
});
});
describe("normal behavior", () => {
test("built-in Array function", () => {
var a = Reflect.construct(Array, [5]);
expect(a instanceof Array).toBeTrue();
expect(a).toHaveLength(5);
});
test("built-in Array function", () => {
var a = Reflect.construct(Array, [5]);
expect(a instanceof Array).toBeTrue();
expect(a).toHaveLength(5);
});
test("built-in String function", () => {
var s = Reflect.construct(String, [123]);
expect(s instanceof String).toBeTrue();
expect(s).toHaveLength(3);
expect(s.toString()).toBe("123");
});
test("built-in String function", () => {
var s = Reflect.construct(String, [123]);
expect(s instanceof String).toBeTrue();
expect(s).toHaveLength(3);
expect(s.toString()).toBe("123");
});
test("user-defined function", () => {
function Foo() {
this.name = "foo";
}
test("user-defined function", () => {
function Foo() {
this.name = "foo";
}
var o = Reflect.construct(Foo, []);
expect(o.name).toBe("foo");
expect(o instanceof Foo).toBeTrue();
});
var o = Reflect.construct(Foo, []);
expect(o.name).toBe("foo");
expect(o instanceof Foo).toBeTrue();
});
test("user-defined function with different new target", () => {
function Foo() {
this.name = "foo";
}
function Bar() {
this.name = "bar";
}
test("user-defined function with different new target", () => {
function Foo() {
this.name = "foo";
}
var o = Reflect.construct(Foo, [], Bar);
expect(o.name).toBe("foo");
expect(o instanceof Foo).toBeFalse();
expect(o instanceof Bar).toBeTrue();
});
function Bar() {
this.name = "bar";
}
var o = Reflect.construct(Foo, [], Bar);
expect(o.name).toBe("foo");
expect(o instanceof Foo).toBeFalse();
expect(o instanceof Bar).toBeTrue();
});
});