@@ -116,9 +116,14 @@ describe("deepinfra image generation provider", () => {
|
116 | 116 | }, |
117 | 117 | }), |
118 | 118 | ); |
119 | | -expect(result.images[0]?.mimeType).toBe("image/jpeg"); |
120 | | -expect(result.images[0]?.fileName).toBe("image-1.jpg"); |
121 | | -expect(result.images[0]?.revisedPrompt).toBe("red square"); |
| 119 | +expect(result.images).toHaveLength(1); |
| 120 | +const [firstImage] = result.images; |
| 121 | +if (!firstImage) { |
| 122 | +throw new Error("Expected generated DeepInfra image"); |
| 123 | +} |
| 124 | +expect(firstImage.mimeType).toBe("image/jpeg"); |
| 125 | +expect(firstImage.fileName).toBe("image-1.jpg"); |
| 126 | +expect(firstImage.revisedPrompt).toBe("red square"); |
122 | 127 | expect(release).toHaveBeenCalledOnce(); |
123 | 128 | }); |
124 | 129 | |
@@ -152,11 +157,20 @@ describe("deepinfra image generation provider", () => {
|
152 | 157 | url: "https://api.deepinfra.com/v1/openai/images/edits", |
153 | 158 | }), |
154 | 159 | ); |
155 | | -const form = postMultipartRequestMock.mock.calls[0]?.[0].body as FormData; |
| 160 | +const firstCall = postMultipartRequestMock.mock.calls[0]; |
| 161 | +if (!firstCall) { |
| 162 | +throw new Error("Expected DeepInfra multipart request"); |
| 163 | +} |
| 164 | +const form = firstCall[0].body as FormData; |
156 | 165 | expect(form.get("model")).toBe("black-forest-labs/FLUX-1-schnell"); |
157 | 166 | expect(form.get("prompt")).toBe("make it neon"); |
158 | 167 | expect(form.get("response_format")).toBe("b64_json"); |
159 | 168 | expect(form.get("image")).toBeInstanceOf(File); |
160 | | -expect(result.images[0]?.mimeType).toBe("image/png"); |
| 169 | +expect(result.images).toHaveLength(1); |
| 170 | +const [image] = result.images; |
| 171 | +if (!image) { |
| 172 | +throw new Error("Expected edited DeepInfra image"); |
| 173 | +} |
| 174 | +expect(image.mimeType).toBe("image/png"); |
161 | 175 | }); |
162 | 176 | }); |