Skip to content

Commit

Permalink
add test for useLiveQuery using WHERE ANY
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor committed Feb 17, 2025
1 parent 78e1fa8 commit 9530213
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/pglite-vue/test/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,32 @@ describe('hooks', () => {
},
])
})

it('updates when query contains WHERE ANY', async () => {
const { useLiveQuery } = await import('../src')
await db.exec(`INSERT INTO test (name) VALUES ('test1'),('test2');`)

const ids = await db.query(`SELECT id FROM test`)
expect(ids.rows.length).toBe(2)

const result = useLiveQuery(`SELECT * FROM test WHERE id = ANY($1)`, [
[1, 2],
])
await flushPromises()

await db.exec(`UPDATE test SET name = 'foobar' WHERE name = 'test2';`)
await flushPromises()
expect(result?.rows?.value).toEqual([
{
id: 1,
name: 'test1',
},
{
id: 2,
name: 'foobar',
},
])
})
})
})
function testLiveQuery(queryHook: 'useLiveQuery' | 'useLiveIncrementalQuery') {
Expand Down

0 comments on commit 9530213

Please sign in to comment.