@@ -50,11 +50,10 @@ describe('rephrase text', () => {
5050 ) ;
5151 } ) ;
5252
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 ( ) => {
53+ it ( 'should throw an error if both style and tone are provided' , async ( ) => {
5554 const deeplClient = makeDeeplClient ( ) ;
5655 const deeplClientPromise = deeplClient . rephraseText (
57- exampleText . de ,
56+ exampleText . en ,
5857 'en' ,
5958 WritingStyle . BUSINESS ,
6059 WritingTone . CONFIDENT ,
@@ -63,6 +62,45 @@ describe('rephrase text', () => {
6362 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 / ) ;
6463 } ) ;
6564
65+ it ( 'should return success if style is default and tone is provided' , async ( ) => {
66+ const deeplClient = makeDeeplClient ( ) ;
67+ const rephraseResponse = await deeplClient . rephraseText (
68+ exampleText . en ,
69+ 'en' ,
70+ WritingStyle . DEFAULT ,
71+ WritingTone . CONFIDENT ,
72+ ) ;
73+ expect ( rephraseResponse . text ) . toBeDefined ( ) ;
74+ expect ( rephraseResponse . detectedSourceLang ) . toBeDefined ( ) ;
75+ expect ( rephraseResponse . targetLang ) . toBe ( 'en-US' ) ;
76+ } ) ;
77+
78+ it ( 'should return success if style is provided and tone is default' , async ( ) => {
79+ const deeplClient = makeDeeplClient ( ) ;
80+ const rephraseResponse = await deeplClient . rephraseText (
81+ exampleText . de ,
82+ 'en' ,
83+ WritingStyle . ACADEMIC ,
84+ WritingTone . DEFAULT ,
85+ ) ;
86+ expect ( rephraseResponse . text ) . toBeDefined ( ) ;
87+ expect ( rephraseResponse . detectedSourceLang ) . toBeDefined ( ) ;
88+ expect ( rephraseResponse . targetLang ) . toBe ( 'en-US' ) ;
89+ } ) ;
90+
91+ it ( 'should return success if both style and tone are not provided' , async ( ) => {
92+ const deeplClient = makeDeeplClient ( ) ;
93+ const rephraseResponse = await deeplClient . rephraseText (
94+ exampleText . de ,
95+ 'en' ,
96+ null ,
97+ undefined ,
98+ ) ;
99+ expect ( rephraseResponse . text ) . toBeDefined ( ) ;
100+ expect ( rephraseResponse . detectedSourceLang ) . toBeDefined ( ) ;
101+ expect ( rephraseResponse . targetLang ) . toBe ( 'en-US' ) ;
102+ } ) ;
103+
66104 it (
67105 'should rephrase with style and tone' ,
68106 async ( ) => {
0 commit comments