Object.getOwnPropertySymbols.js 541 B

12345678910111213141516
  1. test("use with array", () => {
  2. let names = Object.getOwnPropertySymbols([1, 2, 3]);
  3. console.log(names);
  4. expect(names).toEqual([]);
  5. });
  6. test("use with object", () => {
  7. let names = Object.getOwnPropertySymbols({ [Symbol.iterator]: 1, [Symbol.species]: 2 });
  8. expect(names).toEqual([Symbol.iterator, Symbol.species]);
  9. });
  10. test("use with object with string keys", () => {
  11. let symbol = Symbol("bar");
  12. let names = Object.getOwnPropertySymbols({ foo: 1, [symbol]: 2, baz: 3 });
  13. expect(names).toEqual([symbol]);
  14. });