fork of hey-api/openapi-ts because I need some additional things
1import { describe, expect, it } from 'vitest';
2
3import { createClient } from '../client';
4
5describe('buildUrl', () => {
6 const client = createClient();
7
8 const scenarios: {
9 options: Parameters<typeof client.buildUrl>[0];
10 url: string;
11 }[] = [
12 {
13 options: {
14 url: '',
15 },
16 url: '/',
17 },
18 {
19 options: {
20 url: '/foo',
21 },
22 url: '/foo',
23 },
24 {
25 options: {
26 path: {
27 fooId: 1,
28 },
29 url: '/foo/{fooId}',
30 },
31 url: '/foo/1',
32 },
33 {
34 options: {
35 path: {
36 fooId: 1,
37 },
38 query: {
39 bar: 'baz',
40 },
41 url: '/foo/{fooId}',
42 },
43 url: '/foo/1?bar=baz',
44 },
45 ];
46
47 it.each(scenarios)('returns $url', ({ options, url }) => {
48 expect(client.buildUrl(options)).toBe(url);
49 });
50});