@@ -14,7 +14,7 @@ import {
1414 withMockServer ,
1515 withRealServer ,
1616} from './core' ;
17- import { QuotaExceededError , TranslateTextOptions } from 'deepl-node' ;
17+ import { ModelType , QuotaExceededError , TranslateTextOptions } from 'deepl-node' ;
1818
1919describe ( 'translate text' , ( ) => {
2020 it ( 'should translate a single text' , async ( ) => {
@@ -25,6 +25,19 @@ describe('translate text', () => {
2525 expect ( result . billedCharacters ) . toBe ( exampleText . en . length ) ;
2626 } ) ;
2727
28+ it . each ( [ [ 'quality_optimized' ] , [ 'latency_optimized' ] , [ 'prefer_quality_optimized' ] ] ) (
29+ 'should translate using model_type = %s' ,
30+ async ( modelTypeStr ) => {
31+ const translator = makeTranslator ( ) ;
32+ const modelType = modelTypeStr as ModelType ;
33+ const result = await translator . translateText ( exampleText . en , 'en' , 'de' , {
34+ modelType : modelType ,
35+ } ) ;
36+ const expectedModelTypeUsed = modelType . replace ( 'prefer_' , '' ) ;
37+ expect ( result . modelTypeUsed ) . toBe ( expectedModelTypeUsed ) ;
38+ } ,
39+ ) ;
40+
2841 it ( 'should translate an array of texts' , async ( ) => {
2942 const translator = makeTranslator ( ) ;
3043 const result = await translator . translateText ( [ exampleText . fr , exampleText . en ] , null , 'de' ) ;
0 commit comments