Skip to content

Commit 2fa2938

Browse files
authored
test: fix test for query mismatch after update event (#59)
1 parent ae0a5cf commit 2fa2938

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/useFind.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,14 @@ describe('Find composition', () => {
544544
expect(findComposition && findComposition.data.value).toContainEqual(testModel);
545545
});
546546

547-
it('should listen to "patch" & "update" events and remove item from list when query is not matching anymore', () => {
548-
expect.assertions(2);
547+
it('should listen to "patch" & "update" events and remove item from list when query is not matching anymore', async () => {
548+
expect.assertions(4);
549549

550550
// given
551551
const emitter = eventHelper();
552552
const feathersMock = {
553553
service: () => ({
554-
find: jest.fn(() => testModels),
554+
find: jest.fn(() => [testModel]),
555555
on: emitter.on,
556556
off: jest.fn(),
557557
}),
@@ -564,6 +564,11 @@ describe('Find composition', () => {
564564
findComposition = useFind('testModels', ref({ query: { category: testModel.category } }));
565565
});
566566

567+
// before then to ensure that the previous loading procedure is completed
568+
await nextTick();
569+
expect(findComposition && findComposition.isLoading.value).toBeFalsy();
570+
expect(findComposition && findComposition.data.value).toStrictEqual([testModel]);
571+
567572
// when
568573
emitter.emit('updated', changedTestModel);
569574

0 commit comments

Comments
 (0)