blessing-skin-server/resources/assets/tests/js/event.test.js
2018-09-07 10:14:31 +08:00

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