Skip to content

Commit ec3efc6

Browse files
committed
test: add unit test to ensure markReady is not called when source collection sync does not trigger it
1 parent bbed2f2 commit ec3efc6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/db/tests/query/live-query-collection.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,23 @@ describe(`createLiveQueryCollection`, () => {
170170
expect(liveQuery.status).toBe(`ready`)
171171
expect(liveQuery.size).toBe(0)
172172
})
173+
174+
it(`shouldn't call markReady when source collection sync doesn't call markReady`, async () => {
175+
const collection = createCollection<{ id: string }>({
176+
sync: {
177+
sync({ begin, commit }) {
178+
begin()
179+
commit()
180+
},
181+
},
182+
getKey: (item) => item.id,
183+
startSync: true,
184+
})
185+
186+
const liveQuery = createLiveQueryCollection({
187+
query: (q) => q.from({ collection }),
188+
startSync: true,
189+
})
190+
expect(liveQuery.isReady()).toBe(false)
191+
})
173192
})

0 commit comments

Comments
 (0)