diff options
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js')
-rw-r--r-- | Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js b/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js deleted file mode 100644 index fc9b5f172e..0000000000 --- a/Libraries/LibJS/Tests/builtins/Reflect/Reflect.get.js +++ /dev/null @@ -1,67 +0,0 @@ -test("length is 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"); - }); - }); -}); - -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("native getter function", () => { - expect(Reflect.get(String.prototype, "length", "foo")).toBe(3); - }); -}); |