15
15
* limitations under the License.
16
16
*/
17
17
import { describe , it , expect , beforeEach , afterEach , jest } from '@jest/globals' ;
18
- import { AIError } from '../lib/errors' ;
19
18
import {
20
19
mapCountTokensRequest ,
21
20
mapGenerateContentCandidates ,
@@ -74,11 +73,14 @@ describe('Google AI Mappers', () => {
74
73
} ,
75
74
] ,
76
75
} ;
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
+ } ) ,
80
83
) ;
81
- expect ( ( ) => mapGenerateContentRequest ( request ) ) . toThrowError ( error ) ;
82
84
} ) ;
83
85
84
86
it ( 'should warn and round topK if present' , ( ) => {
@@ -90,6 +92,7 @@ describe('Google AI Mappers', () => {
90
92
} ;
91
93
const mappedRequest = mapGenerateContentRequest ( request ) ;
92
94
expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
95
+ expect . any ( String ) , // First argument (timestamp)
93
96
expect . stringContaining ( 'topK in GenerationConfig has been rounded to the nearest integer' ) ,
94
97
) ;
95
98
expect ( mappedRequest . generationConfig ?. topK ) . toBe ( 16 ) ;
@@ -299,7 +302,11 @@ describe('Google AI Mappers', () => {
299
302
} ,
300
303
] ;
301
304
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
+ } ) ,
303
310
) ;
304
311
} ) ;
305
312
0 commit comments