Symbol.js 506 B

12345678910111213141516171819
  1. test("basic functionality", () => {
  2. const s1 = Symbol("foo");
  3. const s2 = Symbol("foo");
  4. expect(s1).not.toBe(s2);
  5. expect(s1.description).toBe("foo");
  6. expect(s2.description).toBe("foo");
  7. s1.description = "bar";
  8. expect(s1.description).toBe("foo");
  9. expect(typeof s1).toBe("symbol");
  10. });
  11. test("constructing symbol from symbol is an error", () => {
  12. expect(() => {
  13. Symbol(Symbol("foo"));
  14. }).toThrowWithMessage(TypeError, "Cannot convert symbol to string");
  15. });