Skip to content

Commit bd467c5

Browse files
committed
refactor(useConnectMutation): update invalidate assertioins after mutation completes
1 parent fc05fef commit bd467c5

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

packages/react/src/data-connect/useConnectMutation.test.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ describe("useConnectMutation", () => {
376376
wrapper,
377377
}
378378
);
379-
380379
const movie = {
381380
title: "TanStack Query Firebase",
382381
genre: "invalidate_option_test",
@@ -391,9 +390,11 @@ describe("useConnectMutation", () => {
391390
expect(result.current.status).toBe("success");
392391
});
393392

394-
expect(invalidateQueriesSpy).toHaveBeenCalledWith({
395-
queryKey: [listMoviesRef().name, undefined],
396-
});
393+
expect(invalidateQueriesSpy).toHaveBeenCalledWith(
394+
expect.objectContaining({
395+
queryKey: [listMoviesRef().name, null],
396+
})
397+
);
397398
});
398399

399400
test("invalidates queries specified in the invalidate option for upsert mutations", async () => {
@@ -445,9 +446,11 @@ describe("useConnectMutation", () => {
445446
expect(upsertMutationResult.current.data?.movie_upsert.id).toBe(movieId);
446447
});
447448

448-
expect(invalidateQueriesSpy).toHaveBeenCalledWith({
449-
queryKey: [listMoviesRef().name, undefined],
450-
});
449+
expect(invalidateQueriesSpy).toHaveBeenCalledWith(
450+
expect.objectContaining({
451+
queryKey: [listMoviesRef().name, null],
452+
})
453+
);
451454
});
452455

453456
test("invalidates queries specified in the invalidate option for delete mutations", async () => {
@@ -497,9 +500,11 @@ describe("useConnectMutation", () => {
497500
expect(deleteMutationResult.current.data?.movie_delete?.id).toBe(movieId);
498501
});
499502

500-
expect(invalidateQueriesSpy).toHaveBeenCalledWith({
501-
queryKey: [listMoviesRef().name, undefined],
502-
});
503+
expect(invalidateQueriesSpy).toHaveBeenCalledWith(
504+
expect.objectContaining({
505+
queryKey: [listMoviesRef().name, null],
506+
})
507+
);
503508
});
504509

505510
test("calls onSuccess callback after successful create mutation", async () => {

0 commit comments

Comments
 (0)