diff --git a/components/utils/test/EventBus.spec.js b/components/utils/test/EventBus.spec.js new file mode 100644 index 000000000..7cc03d5e1 --- /dev/null +++ b/components/utils/test/EventBus.spec.js @@ -0,0 +1,24 @@ +import EventBus from '../EventBus'; + +describe('EventBus', () => { + it('When eventbus is on, callback should be emitted', () => { + const eventBus = new EventBus(); + const callback = vi.fn(); + + eventBus.on('test', callback); + eventBus.emit('test'); + + expect(callback).toHaveBeenCalled(); + }); + + it('When eventbus is off, callback should be emitted', () => { + const eventBus = new EventBus(); + const callback = vi.fn(); + + eventBus.on('test', callback); + eventBus.off('test', callback); + eventBus.emit('test'); + + expect(callback).not.toHaveBeenCalled(); + }); +});