| 28 | } |
| 29 | |
| 30 | function makeClient( |
| 31 | fetchImpl: typeof fetch, |
| 32 | options: { apiKey?: string | null; onDebug?: (e: DebugEvent) => void } = {}, |
| 33 | ): HttpClient { |
| 34 | const apiKey = 'apiKey' in options ? (options.apiKey ?? undefined) : 'sk-test'; |
| 35 | return new HttpClient({ |
| 36 | baseUrl: 'https://api.example.com/api/cli/v1', |
| 37 | apiKey, |
| 38 | fetchImpl, |
| 39 | sleep: () => Promise.resolve(), |
| 40 | random: () => 0, |
| 41 | onDebug: options.onDebug, |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | describe('buildUrl', () => { |
| 46 | it('handles trailing slashes and absolute paths', () => { |