EventBus test update

pull/3518/head^2
Bahadır Sofuoğlu 2023-01-10 17:17:21 +03:00
parent fd35b618e5
commit 480dda1d7c
1 changed files with 24 additions and 0 deletions

View File

@ -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();
});
});