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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
import Hook from '~/droplab/hook';
import DropDown from '~/droplab/drop_down';
jest.mock('~/droplab/drop_down', () => jest.fn());
describe('Hook', () => {
let testContext;
beforeEach(() => {
testContext = {};
});
describe('class constructor', () => {
beforeEach(() => {
testContext.trigger = { id: 'id' };
testContext.list = {};
testContext.plugins = {};
testContext.config = {};
testContext.hook = new Hook(
testContext.trigger,
testContext.list,
testContext.plugins,
testContext.config,
);
});
it('should set .trigger', () => {
expect(testContext.hook.trigger).toBe(testContext.trigger);
});
it('should set .list', () => {
expect(testContext.hook.list).toEqual({});
});
it('should call DropDown constructor', () => {
expect(DropDown).toHaveBeenCalledWith(testContext.list, testContext.config);
});
it('should set .type', () => {
expect(testContext.hook.type).toBe('Hook');
});
it('should set .event', () => {
expect(testContext.hook.event).toBe('click');
});
it('should set .plugins', () => {
expect(testContext.hook.plugins).toBe(testContext.plugins);
});
it('should set .config', () => {
expect(testContext.hook.config).toBe(testContext.config);
});
it('should set .id', () => {
expect(testContext.hook.id).toBe(testContext.trigger.id);
});
describe('if config argument is undefined', () => {
beforeEach(() => {
testContext.config = undefined;
testContext.hook = new Hook(
testContext.trigger,
testContext.list,
testContext.plugins,
testContext.config,
);
});
it('should set .config to an empty object', () => {
expect(testContext.hook.config).toEqual({});
});
});
describe('if plugins argument is undefined', () => {
beforeEach(() => {
testContext.plugins = undefined;
testContext.hook = new Hook(
testContext.trigger,
testContext.list,
testContext.plugins,
testContext.config,
);
});
it('should set .plugins to an empty array', () => {
expect(testContext.hook.plugins).toEqual([]);
});
});
});
});
|