-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test coverage for throw custom error
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import process from 'node:process'; | ||
import dotenv from 'dotenv'; | ||
import {describe, expect, it} from 'vitest'; | ||
import {initializeClient} from './setup.js'; | ||
|
||
dotenv.config(); | ||
|
||
const username = process.env.ZENDESK_USERNAME; | ||
const token = process.env.ZENDESK_TOKEN; | ||
|
||
describe('Zendesk Exceptions Handling', () => { | ||
it('should throw an error for an invalid subdomain', async () => { | ||
const error = new Error('My Custom Error'); | ||
error.details = 'Custom Details'; | ||
|
||
const client = initializeClient({ | ||
username, | ||
token, | ||
subdomain: 'any', | ||
throwOriginalException: true, | ||
transportConfig: { | ||
transportFn() { | ||
throw error; | ||
}, | ||
}, | ||
}); | ||
|
||
await expect(() => client.users.me()).rejects.toThrowError(error); | ||
}); | ||
}); |