ladybird/Userland/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyNames.js
Andreas Kling f86e241699 LibJS: Object.getOwnPropertyNames() should enumerate String's .length
We were incorrectly aborting property name enumeration after generating
names for all the indexable properties in the underlying string.
2021-06-19 11:46:08 +02:00

19 lines
645 B
JavaScript

test("use with array", () => {
let names = Object.getOwnPropertyNames([1, 2, 3]);
expect(names).toEqual(["0", "1", "2", "length"]);
});
test("use with object", () => {
let names = Object.getOwnPropertyNames({ foo: 1, bar: 2, baz: 3 });
expect(names).toEqual(["foo", "bar", "baz"]);
});
test("use with object with symbol keys", () => {
let names = Object.getOwnPropertyNames({ foo: 1, [Symbol("bar")]: 2, baz: 3 });
expect(names).toEqual(["foo", "baz"]);
});
test("use with String object", () => {
let names = Object.getOwnPropertyNames(new String("foo"));
expect(names).toEqual(["0", "1", "2", "length"]);
});