Skip to content

Commit

Permalink
Compare e.json roundtrip to JSON.stringify->parse (#1112)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
scotttrinh authored Oct 2, 2024
1 parent 8c23f40 commit a14e811
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions integration-tests/lts/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit a14e811

Please sign in to comment.