mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 18:31:13 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
51
Libraries/LibJS/Tests/builtins/Object/Object.keys.js
Normal file
51
Libraries/LibJS/Tests/builtins/Object/Object.keys.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length", () => {
|
||||
expect(Object.keys).toHaveLength(1);
|
||||
expect(Object.keys(true)).toHaveLength(0);
|
||||
expect(Object.keys(45)).toHaveLength(0);
|
||||
expect(Object.keys(-998)).toHaveLength(0);
|
||||
expect(Object.keys("abcd")).toHaveLength(4);
|
||||
expect(Object.keys([1, 2, 3])).toHaveLength(3);
|
||||
expect(Object.keys({ a: 1, b: 2, c: 3 })).toHaveLength(3);
|
||||
});
|
||||
|
||||
test("object argument", () => {
|
||||
let keys = Object.keys({ foo: 1, bar: 2, baz: 3 });
|
||||
expect(keys).toEqual(["foo", "bar", "baz"]);
|
||||
});
|
||||
|
||||
test("object argument with symbol keys", () => {
|
||||
let keys = Object.keys({ foo: 1, [Symbol("bar")]: 2, baz: 3 });
|
||||
expect(keys).toEqual(["foo", "baz"]);
|
||||
});
|
||||
|
||||
test("array argument", () => {
|
||||
let keys = Object.keys(["a", "b", "c"]);
|
||||
expect(keys).toEqual(["0", "1", "2"]);
|
||||
});
|
||||
|
||||
test("ignores non-enumerable properties", () => {
|
||||
let obj = { foo: 1 };
|
||||
Object.defineProperty(obj, "getFoo", {
|
||||
value: function () {
|
||||
return this.foo;
|
||||
},
|
||||
});
|
||||
keys = Object.keys(obj);
|
||||
expect(keys).toEqual(["foo"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("null argument value", () => {
|
||||
expect(() => {
|
||||
Object.keys(null);
|
||||
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
|
||||
});
|
||||
|
||||
test("undefined argument value", () => {
|
||||
expect(() => {
|
||||
Object.keys(undefined);
|
||||
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue