UNPKG

@hey-api/client-fetch

Version:

🚀 Fetch API client for `@hey-api/openapi-ts` codegen.

51 lines (46 loc) • 860 B
import { describe, expect, it } from 'vitest'; import { createClient } from '../client'; describe('buildUrl', () => { const client = createClient(); const scenarios: { options: Parameters<typeof client.buildUrl>[0]; url: string; }[] = [ { options: { url: '', }, url: '/', }, { options: { url: '/foo', }, url: '/foo', }, { options: { path: { fooId: 1, }, url: '/foo/{fooId}', }, url: '/foo/1', }, { options: { path: { fooId: 1, }, query: { bar: 'baz', }, url: '/foo/{fooId}', }, url: '/foo/1?bar=baz', }, ]; it.each(scenarios)('returns $url', ({ options, url }) => { expect(client.buildUrl(options)).toBe(url); }); });