summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js')
-rw-r--r--Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js108
1 files changed, 54 insertions, 54 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js b/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js
index 9dc1e2e392..d22322450b 100644
--- a/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js
+++ b/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js
@@ -1,63 +1,63 @@
test("length is 2", () => {
- expect(Reflect.get).toHaveLength(2);
+ expect(Reflect.get).toHaveLength(2);
});
describe("errors", () => {
- test("target must be an object", () => {
- [null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
- expect(() => {
- Reflect.get(value);
- }).toThrowWithMessage(TypeError, "First argument of Reflect.get() must be an object");
- });
+ test("target must be an object", () => {
+ [null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
+ expect(() => {
+ Reflect.get(value);
+ }).toThrowWithMessage(TypeError, "First argument of Reflect.get() must be an object");
});
+ });
});
describe("normal behavior", () => {
- test("regular object", () => {
- expect(Reflect.get({})).toBeUndefined();
- expect(Reflect.get({ undefined: 1 })).toBe(1);
- expect(Reflect.get({ foo: 1 })).toBeUndefined();
- expect(Reflect.get({ foo: 1 }, "foo")).toBe(1);
- });
-
- test("array", () => {
- expect(Reflect.get([])).toBeUndefined();
- expect(Reflect.get([1, 2, 3])).toBeUndefined();
- expect(Reflect.get([1, 2, 3], "0")).toBe(1);
- expect(Reflect.get([1, 2, 3], 0)).toBe(1);
- expect(Reflect.get([1, 2, 3], 1)).toBe(2);
- expect(Reflect.get([1, 2, 3], 2)).toBe(3);
- expect(Reflect.get([1, 2, 3], 4)).toBeUndefined();
- });
-
- test("string object", () => {
- expect(Reflect.get(new String())).toBeUndefined();
- expect(Reflect.get(new String(), 0)).toBeUndefined();
- expect(Reflect.get(new String("foo"), "0")).toBe("f");
- expect(Reflect.get(new String("foo"), 0)).toBe("f");
- expect(Reflect.get(new String("foo"), 1)).toBe("o");
- expect(Reflect.get(new String("foo"), 2)).toBe("o");
- expect(Reflect.get(new String("foo"), 3)).toBeUndefined();
- });
-
- test("getter function", () => {
- const foo = {
- get prop() {
- this.getPropCalled = true;
- }
- };
- const bar = {};
- Object.setPrototypeOf(bar, foo);
-
- expect(foo.getPropCalled).toBeUndefined();
- expect(bar.getPropCalled).toBeUndefined();
-
- Reflect.get(bar, "prop");
- expect(foo.getPropCalled).toBeUndefined();
- expect(bar.getPropCalled).toBeTrue();
-
- Reflect.get(bar, "prop", foo);
- expect(foo.getPropCalled).toBeTrue();
- expect(bar.getPropCalled).toBeTrue();
- });
+ test("regular object", () => {
+ expect(Reflect.get({})).toBeUndefined();
+ expect(Reflect.get({ undefined: 1 })).toBe(1);
+ expect(Reflect.get({ foo: 1 })).toBeUndefined();
+ expect(Reflect.get({ foo: 1 }, "foo")).toBe(1);
+ });
+
+ test("array", () => {
+ expect(Reflect.get([])).toBeUndefined();
+ expect(Reflect.get([1, 2, 3])).toBeUndefined();
+ expect(Reflect.get([1, 2, 3], "0")).toBe(1);
+ expect(Reflect.get([1, 2, 3], 0)).toBe(1);
+ expect(Reflect.get([1, 2, 3], 1)).toBe(2);
+ expect(Reflect.get([1, 2, 3], 2)).toBe(3);
+ expect(Reflect.get([1, 2, 3], 4)).toBeUndefined();
+ });
+
+ test("string object", () => {
+ expect(Reflect.get(new String())).toBeUndefined();
+ expect(Reflect.get(new String(), 0)).toBeUndefined();
+ expect(Reflect.get(new String("foo"), "0")).toBe("f");
+ expect(Reflect.get(new String("foo"), 0)).toBe("f");
+ expect(Reflect.get(new String("foo"), 1)).toBe("o");
+ expect(Reflect.get(new String("foo"), 2)).toBe("o");
+ expect(Reflect.get(new String("foo"), 3)).toBeUndefined();
+ });
+
+ test("getter function", () => {
+ const foo = {
+ get prop() {
+ this.getPropCalled = true;
+ },
+ };
+ const bar = {};
+ Object.setPrototypeOf(bar, foo);
+
+ expect(foo.getPropCalled).toBeUndefined();
+ expect(bar.getPropCalled).toBeUndefined();
+
+ Reflect.get(bar, "prop");
+ expect(foo.getPropCalled).toBeUndefined();
+ expect(bar.getPropCalled).toBeTrue();
+
+ Reflect.get(bar, "prop", foo);
+ expect(foo.getPropCalled).toBeTrue();
+ expect(bar.getPropCalled).toBeTrue();
+ });
});