JSON.stringify-proxy.js 303 B

1234567891011
  1. test("basic functionality", () => {
  2. let p = new Proxy([], {
  3. get(_, key) {
  4. if (key === "length") return 3;
  5. return Number(key);
  6. },
  7. });
  8. expect(JSON.stringify(p)).toBe("[0,1,2]");
  9. expect(JSON.stringify([[new Proxy(p, {})]])).toBe("[[[0,1,2]]]");
  10. });