Skip to content

Commit

Permalink
Unit test for float conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-dp committed Oct 25, 2023
1 parent 30a03c2 commit 9410203
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions clients/typescript/test/client/conversions/sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,37 @@ test.serial('booleans are converted correctly to SQLite', async (t) => {
{ id: 2, bool: 0 },
])
})

test.serial('floats are converted correctly to SQLite', async (t) => {
await tbl.createMany({
data: [
{
id: 1,
float8: 1.234,
},
{
id: 2,
float8: NaN,
},
{
id: 3,
float8: +Infinity,
},
{
id: 4,
float8: -Infinity,
},
],
})

const rawRes = await electric.db.raw({
sql: 'SELECT id, float8 FROM DataTypes ORDER BY id ASC',
args: [],
})
t.deepEqual(rawRes, [
{ id: 1, float8: 1.234 },
{ id: 2, float8: 'NaN' },
{ id: 3, float8: Infinity },
{ id: 4, float8: -Infinity },
])
})

0 comments on commit 9410203

Please sign in to comment.