Files
workavia-calendar-front/__test__/features/Error/ErrorHandler.test.tsx
T
lethemanh cadfa70e60 #708 apply strictier linting rules (#717)
* #708 apply strictier linting rules and fix simple eslint bugs

* #708 fix eslint errors relate to promise

* #708 fix eslint import/no-extraneous-dependencies

* #708 fix eslint errors of react-hook

* #708 enable eslint check for typescript

---------

Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
2026-04-01 17:15:10 +02:00

36 lines
1000 B
TypeScript

import { EventErrorHandler } from '@/components/Error/EventErrorHandler'
describe('EventErrorHandler', () => {
it('calls the callback when a new error is reported', () => {
const handler = new EventErrorHandler()
const callback = jest.fn()
handler.setErrorCallback(callback)
handler.reportError('123', 'Something broke')
expect(callback).toHaveBeenCalledWith(['Something broke'])
})
it('does not duplicate errors for same eventId', () => {
const handler = new EventErrorHandler()
const callback = jest.fn()
handler.setErrorCallback(callback)
handler.reportError('A', 'Error 1')
handler.reportError('A', 'Error 1 again')
expect(callback).toHaveBeenCalledTimes(1)
})
it('clears errors properly', () => {
const handler = new EventErrorHandler()
const callback = jest.fn()
handler.setErrorCallback(callback)
handler.reportError('A', 'Error 1')
handler.clearAll()
expect(callback).toHaveBeenLastCalledWith([])
})
})