-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for error utilities
- Loading branch information
1 parent
f9b7a6c
commit 0d9dd95
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
packages/analytics-js-common/__tests__/utilities/errors.test.ts
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,13 @@ | ||
import { dispatchErrorEvent } from '../../src/utilities/errors'; | ||
|
||
describe('Errors - utilities', () => { | ||
describe('dispatchErrorEvent', () => { | ||
it('should dispatch an error event', () => { | ||
const dispatchEvent = jest.fn(); | ||
globalThis.dispatchEvent = dispatchEvent; | ||
const error = new Error('Test error'); | ||
dispatchErrorEvent(error); | ||
expect(dispatchEvent).toHaveBeenCalledWith(new ErrorEvent('error', { error })); | ||
}); | ||
}); | ||
}); |
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