|
1 | 1 | import * as fetchMock from 'fetch-mock-jest'; |
2 | 2 | import { initContract } from '..'; |
3 | 3 | import { ApiFetcherArgs, initClient } from './client'; |
| 4 | +import { Equal, Expect } from './test-helpers'; |
4 | 5 |
|
5 | 6 | import { z } from 'zod'; |
6 | 7 |
|
@@ -124,6 +125,33 @@ const client = initClient(router, { |
124 | 125 | baseHeaders: {}, |
125 | 126 | }); |
126 | 127 |
|
| 128 | +type ClientGetPostsType = Expect< |
| 129 | + Equal< |
| 130 | + Parameters<typeof client.posts.getPosts>[0], |
| 131 | + | { |
| 132 | + query?: { |
| 133 | + take?: number; |
| 134 | + skip?: number; |
| 135 | + order?: string; |
| 136 | + }; |
| 137 | + headers?: Record<string, string>; |
| 138 | + } |
| 139 | + | undefined |
| 140 | + > |
| 141 | +>; |
| 142 | + |
| 143 | +type ClientGetPostType = Expect< |
| 144 | + Equal< |
| 145 | + Parameters<typeof client.posts.getPost>[0], |
| 146 | + { |
| 147 | + params: { |
| 148 | + id: string; |
| 149 | + }; |
| 150 | + headers?: Record<string, string>; |
| 151 | + } |
| 152 | + > |
| 153 | +>; |
| 154 | + |
127 | 155 | describe('client', () => { |
128 | 156 | beforeEach(() => { |
129 | 157 | fetchMock.mockReset(); |
@@ -497,6 +525,35 @@ const customClient = initClient(router, { |
497 | 525 | }, |
498 | 526 | }); |
499 | 527 |
|
| 528 | +type CustomClientGetPostsType = Expect< |
| 529 | + Equal< |
| 530 | + Parameters<typeof customClient.posts.getPosts>[0], |
| 531 | + | { |
| 532 | + query?: { |
| 533 | + take?: number; |
| 534 | + skip?: number; |
| 535 | + order?: string; |
| 536 | + }; |
| 537 | + headers?: Record<string, string>; |
| 538 | + uploadProgress?: (progress: number) => void; |
| 539 | + } |
| 540 | + | undefined |
| 541 | + > |
| 542 | +>; |
| 543 | + |
| 544 | +type CustomClientGetPostType = Expect< |
| 545 | + Equal< |
| 546 | + Parameters<typeof customClient.posts.getPost>[0], |
| 547 | + { |
| 548 | + params: { |
| 549 | + id: string; |
| 550 | + }; |
| 551 | + headers?: Record<string, string>; |
| 552 | + uploadProgress?: (progress: number) => void; |
| 553 | + } |
| 554 | + > |
| 555 | +>; |
| 556 | + |
500 | 557 | describe('custom api', () => { |
501 | 558 | beforeEach(() => { |
502 | 559 | argsCalledMock.mockReset(); |
|
0 commit comments