|
1 | 1 | import { expect, jest, test } from '@jest/globals'; |
2 | | -import Replicate, { Prediction } from 'replicate'; |
| 2 | +import Replicate, { ApiError, Prediction } from 'replicate'; |
3 | 3 | import nock from 'nock'; |
4 | 4 | import fetch from 'cross-fetch'; |
5 | 5 |
|
@@ -37,14 +37,6 @@ describe('Replicate client', () => { |
37 | 37 | test('Throws error if no auth token is provided', () => { |
38 | 38 | const expected = 'Missing required parameter: auth' |
39 | 39 |
|
40 | | - expect(() => { |
41 | | - new Replicate({ auth: undefined }); |
42 | | - }).toThrow(expected); |
43 | | - |
44 | | - expect(() => { |
45 | | - new Replicate({ auth: null }); |
46 | | - }).toThrow(expected); |
47 | | - |
48 | 40 | expect(() => { |
49 | 41 | new Replicate({ auth: "" }); |
50 | 42 | }).toThrow(expected); |
@@ -156,7 +148,7 @@ describe('Replicate client', () => { |
156 | 148 | nock(BASE_URL) |
157 | 149 | .post('/predictions') |
158 | 150 | .reply(201, (_uri, body) => { |
159 | | - expect(body[ 'stream' ]).toBe(true); |
| 151 | + expect((body as any).stream).toBe(true); |
160 | 152 | return body |
161 | 153 | }) |
162 | 154 |
|
@@ -200,8 +192,8 @@ describe('Replicate client', () => { |
200 | 192 | }, |
201 | 193 | }); |
202 | 194 | } catch (error) { |
203 | | - expect(error.response.status).toBe(400); |
204 | | - expect(error.message).toContain("Invalid input") |
| 195 | + expect((error as ApiError).response.status).toBe(400); |
| 196 | + expect((error as ApiError).message).toContain("Invalid input") |
205 | 197 | } |
206 | 198 | }) |
207 | 199 | // Add more tests for error handling, edge cases, etc. |
|
0 commit comments