19 lines
397 B
JavaScript
19 lines
397 B
JavaScript
import * as emitter from '@/js/event';
|
|
|
|
test('mount variable to global', () => {
|
|
expect(window.bsEmitter).toBeFrozen();
|
|
});
|
|
|
|
test('add listener and emit event', () => {
|
|
const mockA = jest.fn();
|
|
const mockB = jest.fn();
|
|
|
|
emitter.on('a', mockA);
|
|
emitter.on('b', mockB);
|
|
|
|
emitter.emit('a');
|
|
|
|
expect(mockA).toHaveBeenCalledTimes(1);
|
|
expect(mockB).not.toBeCalled();
|
|
});
|