Skip to content

Commit c145203

Browse files
committed
test
1 parent ca70c9c commit c145203

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/openapi-react-query/test/index.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,29 @@ describe("client", () => {
6464
client.queryOptions("get", "/blogposts/{post_id}", {});
6565
});
6666

67+
it("correctly infers return type from query key", async () => {
68+
const fetchClient = createFetchClient<paths>({ baseUrl });
69+
const client = createClient(fetchClient);
70+
71+
const data = queryClient.getQueryData(
72+
client.queryOptions("get", "/blogposts/{post_id}", {
73+
params: {
74+
path: {
75+
post_id: "1",
76+
},
77+
},
78+
}).queryKey
79+
);
80+
81+
expectTypeOf(data).toEqualTypeOf<{
82+
title: string;
83+
body: string;
84+
publish_date?: number;
85+
} | undefined>();
86+
87+
88+
});
89+
6790
it("returns query options that can resolve data correctly with fetchQuery", async () => {
6891
const response = { title: "title", body: "body" };
6992
const fetchClient = createFetchClient<paths>({ baseUrl });

0 commit comments

Comments
 (0)