Object.getOwnPropertySymbols.js 517 B

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