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 24, 2023
1 parent 5ba269f commit 61b6b39
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 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,39 @@ 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 61b6b39

Please sign in to comment.