fork of hey-api/openapi-ts because I need some additional things

Add tests, proving that params are correctly passed to axios as

+52
+52
packages/openapi-ts/src/plugins/@hey-api/client-axios/__tests__/client.test.ts
··· 49 49 it.each(scenarios)('returns $url', ({ options, url }) => { 50 50 expect(client.buildUrl(options)).toBe(url); 51 51 }); 52 + 53 + it.each(scenarios)( 54 + 'correctly maps `query` parameter to `params` parameter for axios', 55 + async ({ options }) => { 56 + const mockAxios = vi.fn((config) => ({ config })); 57 + 58 + expect( 59 + ( 60 + await client.request({ 61 + ...options, 62 + axios: mockAxios as Partial<AxiosInstance> as AxiosInstance, 63 + method: 'GET', 64 + }) 65 + ).config?.params, 66 + ).toBe(options.query); 67 + }, 68 + ); 69 + 70 + it.each(scenarios)( 71 + 'uses a custom `paramsSerializer` method when given and do not map `params` for axios', 72 + async ({ options }) => { 73 + const mockAxios = vi.fn((config) => ({ config })); 74 + 75 + const paramsSerializer = (params: Record<string, string>) => 76 + new URLSearchParams(params).toString(); 77 + 78 + expect( 79 + ( 80 + await client.request({ 81 + ...options, 82 + axios: mockAxios as Partial<AxiosInstance> as AxiosInstance, 83 + method: 'GET', 84 + paramsSerializer, 85 + }) 86 + ).config, 87 + ).toEqual( 88 + expect.objectContaining({ 89 + params: undefined, 90 + paramsSerializer, 91 + }), 92 + ); 93 + }, 94 + ); 52 95 }); 53 96 54 97 describe('AxiosInstance', () => { ··· 350 393 351 394 const config = client.getUri({ baseURL: undefined, url: '/users' }); 352 395 expect(config).toBe('https://api.example.com/users'); 396 + }); 397 + it('does append `params` as searchParams to the URL', async () => { 398 + const client = axios.create({ 399 + baseURL: 'https://api.example.com', 400 + params: { foo: 'bar' }, 401 + }); 402 + 403 + const config = client.getUri({ baseURL: undefined, url: '/users' }); 404 + expect(config).toBe('https://api.example.com/users?foo=bar'); 353 405 }); 354 406 });