2020-07-04 10:09:48 -07:00
|
|
|
test("use with array", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
let names = Object.getOwnPropertyNames([1, 2, 3]);
|
|
|
|
|
expect(names).toEqual(["0", "1", "2", "length"]);
|
2020-07-04 10:09:48 -07:00
|
|
|
});
|
2020-03-29 01:08:25 +01:00
|
|
|
|
2020-07-04 10:09:48 -07:00
|
|
|
test("use with object", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
let names = Object.getOwnPropertyNames({ foo: 1, bar: 2, baz: 3 });
|
|
|
|
|
expect(names).toEqual(["foo", "bar", "baz"]);
|
2020-07-04 10:09:48 -07:00
|
|
|
});
|
2020-07-07 21:39:36 -07:00
|
|
|
|
|
|
|
|
test("use with object with symbol keys", () => {
|
|
|
|
|
let names = Object.getOwnPropertyNames({ foo: 1, [Symbol("bar")]: 2, baz: 3 });
|
|
|
|
|
expect(names).toEqual(["foo", "baz"]);
|
|
|
|
|
});
|
2021-06-19 11:46:08 +02:00
|
|
|
|
|
|
|
|
test("use with String object", () => {
|
|
|
|
|
let names = Object.getOwnPropertyNames(new String("foo"));
|
|
|
|
|
expect(names).toEqual(["0", "1", "2", "length"]);
|
|
|
|
|
});
|