Skip to content

Commit fc05fef

Browse files
committed
test(useConnectQuery): a query with variables has valid query keys including the variables
1 parent 90355f1 commit fc05fef

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,29 @@ describe("useConnectQuery", () => {
207207

208208
expect(dehydrated.queries[0].queryKey).toEqual(["ListMovies", null]);
209209
});
210+
211+
test("a query with variables has valid query keys including the variables", async () => {
212+
const movieData = {
213+
title: "tanstack query firebase",
214+
genre: "library",
215+
imageUrl: "https://invertase.io/",
216+
};
217+
218+
const createdMovie = await createMovie(movieData);
219+
220+
const movieId = createdMovie?.data?.movie_insert?.id;
221+
222+
const queryClient = new DataConnectQueryClient();
223+
224+
await queryClient.prefetchDataConnectQuery(
225+
getMovieByIdRef({ id: movieId })
226+
);
227+
228+
const dehydrated = dehydrate(queryClient);
229+
230+
expect(dehydrated.queries[0].queryKey).toEqual([
231+
"GetMovieById",
232+
{ id: movieId },
233+
]);
234+
});
210235
});

0 commit comments

Comments
 (0)