From a14e811ea7347b0d70c3e6f14801338c94f172c1 Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Wed, 2 Oct 2024 13:09:47 -0400 Subject: [PATCH] Compare e.json roundtrip to JSON.stringify->parse (#1112) This fixes a flaky test because stringifying `-0` results in the string `"0"` instead of `"-0"`, at least on Node. What we really care about is that selecting any arbitrary JSON is the same as a rountrip through JSON.stringify and JSON.parse. --- integration-tests/lts/select.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/integration-tests/lts/select.test.ts b/integration-tests/lts/select.test.ts index 959d3d762..9d4777cd8 100644 --- a/integration-tests/lts/select.test.ts +++ b/integration-tests/lts/select.test.ts @@ -1701,10 +1701,15 @@ SELECT __scope_0_defaultPerson { test("arbitrary json literal", async () => { await fc.assert( fc.asyncProperty(fc.jsonValue(), async (arbitraryJson) => { - const q = e.select(e.json(arbitraryJson)); - const result = await q.run(client); - assert.deepEqual(result, arbitraryJson); + const roundTripped = JSON.parse(JSON.stringify(arbitraryJson)); + const result = await e.select(e.json(arbitraryJson)).run(client); + assert.deepEqual(result, roundTripped); }), ); }); + + test("json literal special case: -0 is 0 in JSON", async () => { + const result = await e.select(e.json(-0)).run(client); + assert.equal(result, 0); + }); });