22// Use of this source code is governed by an MIT
33// license that can be found in the LICENSE file.
44
5- import { exampleText , makeDeeplClient , testTimeout , withRealServer } from './core' ;
5+ import { exampleText , makeDeeplClient , testTimeout , usingMockServer , withRealServer } from './core' ;
66
77import { WritingStyle , WritingTone } from './../src/deeplClient' ;
88
@@ -19,7 +19,7 @@ describe('rephrase text', () => {
1919 const deeplClient = makeDeeplClient ( ) ;
2020 const deeplClientPromise = deeplClient . rephraseText ( exampleText . de , 'ja' ) ;
2121 await expect ( deeplClientPromise ) . rejects . toBeInstanceOf ( Error ) ;
22- await expect ( deeplClientPromise ) . rejects . toThrow ( / V a l u e f o r ' t a r g e t _ l a n g ' n o t s u p p o r t e d / ) ;
22+ await expect ( deeplClientPromise ) . rejects . toThrow ( / V a l u e f o r ' ? t a r g e t _ l a n g ' ? n o t s u p p o r t e d / ) ;
2323 } ) ;
2424
2525 it ( 'should throw an error for unsupported tone' , async ( ) => {
@@ -50,30 +50,38 @@ describe('rephrase text', () => {
5050 ) ;
5151 } ) ;
5252
53- withRealServer (
53+ // TODO: update mock to return error if style and tone are provided
54+ withRealServer ( 'should throw an error if both style and tone are provided' , async ( ) => {
55+ const deeplClient = makeDeeplClient ( ) ;
56+ const deeplClientPromise = deeplClient . rephraseText (
57+ exampleText . de ,
58+ 'en' ,
59+ WritingStyle . BUSINESS ,
60+ WritingTone . CONFIDENT ,
61+ ) ;
62+ await expect ( deeplClientPromise ) . rejects . toBeInstanceOf ( Error ) ;
63+ await expect ( deeplClientPromise ) . rejects . toThrow ( / B o t h w r i t i n g _ s t y l e a n d t o n e d e f i n e d / ) ;
64+ } ) ;
65+
66+ it (
5467 'should rephrase with style and tone' ,
5568 async ( ) => {
5669 const deeplClient = makeDeeplClient ( ) ;
5770 const input = 'How are yo dong guys?' ;
5871
59- const outputConfident = "Tell me how you're doing, guys." ;
72+ const outputConfident = usingMockServer
73+ ? 'proton beam'
74+ : "Tell me how you're doing, guys." ;
6075 expect (
6176 ( await deeplClient . rephraseText ( input , 'en' , null , WritingTone . CONFIDENT ) ) . text ,
6277 ) . toBe ( outputConfident ) ;
6378
64- const outputBusiness = 'Greetings, gentlemen. How are you?' ;
79+ const outputBusiness = usingMockServer
80+ ? 'proton beam'
81+ : 'Greetings, gentlemen. How are you?' ;
6582 expect (
6683 ( await deeplClient . rephraseText ( input , 'en' , WritingStyle . BUSINESS , null ) ) . text ,
6784 ) . toBe ( outputBusiness ) ;
68-
69- const deeplClientPromise = deeplClient . rephraseText (
70- input ,
71- 'en' ,
72- WritingStyle . BUSINESS ,
73- WritingTone . CONFIDENT ,
74- ) ;
75- await expect ( deeplClientPromise ) . rejects . toBeInstanceOf ( Error ) ;
76- await expect ( deeplClientPromise ) . rejects . toThrow ( / B o t h w r i t i n g _ s t y l e a n d t o n e d e f i n e d / ) ;
7785 } ,
7886 testTimeout ,
7987 ) ;
0 commit comments