-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediator.js
42 lines (29 loc) · 1.17 KB
/
mediator.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
34
35
36
37
38
39
40
41
42
describe('Mediator', function () {
it('should be defined', function () {
expect(Mediator).toBeDefined();
});
beforeAll(function () {
this.mediator = new Mediator();
});
describe('mediator function: ', function () {
it('should be defined', function () {
expect(this.mediator.subscribe).toBeDefined();
expect(typeof this.mediator.subscribe).toBe('function');
expect(this.mediator.publish).toBeDefined();
expect(typeof this.mediator.publish).toBe('function');
expect(this.mediator.unsubscribe).toBeDefined();
expect(typeof this.mediator.unsubscribe).toBe('function');
});
});
describe('When mediator was init', function () {
it('channels must be empty', function () {
expect(this.mediator.channels).toEqual({});
});
});
describe('Subscribe to channel', function () {
it('when subscribing to an event', function () {
this.mediator.subscribe('Event', callback);
expect(Object.keys(this.mediator.subscribe).length).toEqual(1);
});
});
});