Skip to content

Commit

Permalink
added test coverage for throw custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
onhate committed Aug 1, 2024
1 parent 864f6b8 commit 9fa6cdb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/exceptionshandling.test.js
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);
});
});

0 comments on commit 9fa6cdb

Please sign in to comment.