| 47 | const mockedRecordExaUsage = jest.mocked(recordExaUsage); |
| 48 | const mockedGetBalanceAndOrgSettings = jest.mocked(getBalanceAndOrgSettings); |
| 49 | const mockedCaptureException = jest.mocked(captureException); |
| 50 | const mockedFetch = jest.fn() as jest.MockedFunction<typeof globalThis.fetch>; |
| 51 | const originalFetch = globalThis.fetch; |
| 52 | |
| 53 | function makeRequest( |
| 54 | path: string, |
| 55 | body: unknown = { query: 'test' }, |
| 56 | headers: Record<string, string> = {} |
| 57 | ) { |
| 58 | return new Request(`http://localhost:3000/api/exa${path}`, { |
| 59 | method: 'POST', |
| 60 | headers: { 'Content-Type': 'application/json', ...headers }, |
| 61 | body: JSON.stringify(body), |
| 62 | }); |