Skip to content

Commit ff008a3

Browse files
test: add tests for languages with unsupported write parameters
1 parent c79c267 commit ff008a3

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/rephraseText.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { exampleText, makeDeeplClient, testTimeout, withRealServer } from './core';
66

7-
import { WritingTone, WritingStyle } from './../src/deeplClient';
7+
import { WritingStyle, WritingTone } from './../src/deeplClient';
88

99
describe('rephrase text', () => {
1010
it('should rephrase a single text', async () => {
@@ -22,6 +22,34 @@ describe('rephrase text', () => {
2222
await expect(deeplClientPromise).rejects.toThrow(/Value for 'target_lang' not supported/);
2323
});
2424

25+
it('should throw an error for unsupported tone', async () => {
26+
const deeplClient = makeDeeplClient();
27+
const deeplClientPromise = deeplClient.rephraseText(
28+
exampleText.de,
29+
'es',
30+
null,
31+
WritingTone.CONFIDENT,
32+
);
33+
await expect(deeplClientPromise).rejects.toBeInstanceOf(Error);
34+
await expect(deeplClientPromise).rejects.toThrow(
35+
/Language Spanish does not support setting a tone/,
36+
);
37+
});
38+
39+
it('should throw an error for invalid writing_style parameter', async () => {
40+
const deeplClient = makeDeeplClient();
41+
const deeplClientPromise = deeplClient.rephraseText(
42+
exampleText.de,
43+
'es',
44+
WritingStyle.BUSINESS,
45+
null,
46+
);
47+
await expect(deeplClientPromise).rejects.toBeInstanceOf(Error);
48+
await expect(deeplClientPromise).rejects.toThrow(
49+
/Language Spanish does not support setting a writing style/,
50+
);
51+
});
52+
2553
withRealServer(
2654
'should rephrase with style and tone',
2755
async () => {

0 commit comments

Comments
 (0)