-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
33 lines (26 loc) · 901 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import IFrameCommunicator from './';
describe('IFrameCommunicator', () => {
describe('constructor()', () => {
it('it stores the given properties', () => {
const com = new IFrameCommunicator('jon', ['d', 'o', 'e']);
expect(com.id).toBe('jon');
expect(com.remainingDeps).toEqual(['d', 'o', 'e']);
});
});
describe('event-management', () => {
it('stores the listener', () => {
function onReady() {}
const com = new IFrameCommunicator('jon', ['doe']);
com.on('ready', onReady);
expect(com.listeners.ready).toBeDefined();
expect(com.listeners.ready[0]).toBe(onReady);
});
it('calls the registrated listener', () => {
const onReady = jest.fn();
const com = new IFrameCommunicator('jon', ['doe']);
com.on('ready', onReady);
com.fire('ready');
expect(onReady).toHaveBeenCalled();
});
});
});