Skip to content

Commit 9fa6cdb

Browse files
committed
added test coverage for throw custom error
1 parent 864f6b8 commit 9fa6cdb

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/exceptionshandling.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import process from 'node:process';
2+
import dotenv from 'dotenv';
3+
import {describe, expect, it} from 'vitest';
4+
import {initializeClient} from './setup.js';
5+
6+
dotenv.config();
7+
8+
const username = process.env.ZENDESK_USERNAME;
9+
const token = process.env.ZENDESK_TOKEN;
10+
11+
describe('Zendesk Exceptions Handling', () => {
12+
it('should throw an error for an invalid subdomain', async () => {
13+
const error = new Error('My Custom Error');
14+
error.details = 'Custom Details';
15+
16+
const client = initializeClient({
17+
username,
18+
token,
19+
subdomain: 'any',
20+
throwOriginalException: true,
21+
transportConfig: {
22+
transportFn() {
23+
throw error;
24+
},
25+
},
26+
});
27+
28+
await expect(() => client.users.me()).rejects.toThrowError(error);
29+
});
30+
});

0 commit comments

Comments
 (0)