primevue-mirror/components/lib/utils/test/EventBus.spec.js

25 lines
648 B
JavaScript
Raw Normal View History

2023-01-10 14:17:21 +00:00
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();
});
});