Skip to content

Commit 70df14a

Browse files
test: fixed another unit test suite
1 parent b886279 commit 70df14a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/ai/__tests__/googleai-mappers.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717
import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals';
18-
import { AIError } from '../lib/errors';
1918
import {
2019
mapCountTokensRequest,
2120
mapGenerateContentCandidates,
@@ -74,11 +73,14 @@ describe('Google AI Mappers', () => {
7473
},
7574
],
7675
};
77-
const error = new AIError(
78-
AIErrorCode.UNSUPPORTED,
79-
'AI: SafetySetting.method is not supported in the the Gemini Developer API. Please remove this property. (AI/unsupported)',
76+
77+
expect(() => mapGenerateContentRequest(request)).toThrowError(
78+
expect.objectContaining({
79+
code: AIErrorCode.UNSUPPORTED,
80+
message:
81+
'AI: SafetySetting.method is not supported in the the Gemini Developer API. Please remove this property. (AI/unsupported)',
82+
}),
8083
);
81-
expect(() => mapGenerateContentRequest(request)).toThrowError(error);
8284
});
8385

8486
it('should warn and round topK if present', () => {
@@ -90,6 +92,7 @@ describe('Google AI Mappers', () => {
9092
};
9193
const mappedRequest = mapGenerateContentRequest(request);
9294
expect(loggerWarnSpy).toHaveBeenCalledWith(
95+
expect.any(String), // First argument (timestamp)
9396
expect.stringContaining('topK in GenerationConfig has been rounded to the nearest integer'),
9497
);
9598
expect(mappedRequest.generationConfig?.topK).toBe(16);
@@ -299,7 +302,11 @@ describe('Google AI Mappers', () => {
299302
},
300303
];
301304
expect(() => mapGenerateContentCandidates(candidates)).toThrowError(
302-
new AIError(AIErrorCode.UNSUPPORTED, 'Part.videoMetadata is not supported'),
305+
expect.objectContaining({
306+
code: AIErrorCode.UNSUPPORTED,
307+
message:
308+
'AI: Part.videoMetadata is not supported in the Gemini Developer API. Please remove this property. (AI/unsupported)',
309+
}),
303310
);
304311
});
305312

0 commit comments

Comments
 (0)