fix: handle malformed ML service responses
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
b81fecaa3f
commit
e84be0d42f
@@ -66,6 +66,12 @@ describe('classifyImage', () => {
|
||||
await expect(classifyImage(makeImageFile())).rejects.toThrow('ML service returned 503: Model is not loaded');
|
||||
});
|
||||
|
||||
test('throws when ML service returns malformed JSON', async () => {
|
||||
mockFetch(async () => new Response('not-json', { status: 200, headers: { 'content-type': 'application/json' } }));
|
||||
|
||||
await expect(classifyImage(makeImageFile())).rejects.toThrow('Invalid ML service JSON response');
|
||||
});
|
||||
|
||||
test('throws when ML service returns an unknown label', async () => {
|
||||
mockFetch(async () => new Response(
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user