1
|
|
|
const ArmUI = require('../src/js/arm-ui'); |
2
|
|
|
|
3
|
|
|
describe('ArmUI testing', () => { |
4
|
|
|
|
5
|
|
|
test('Defining ArmUI', () => { |
6
|
|
|
expect(ArmUI).toBeDefined(); |
7
|
|
|
}); |
8
|
|
|
|
9
|
|
|
test('Defining ArmUI globally', () => { |
10
|
|
|
expect(window.ArmUI).toBeDefined(); |
11
|
|
|
}); |
12
|
|
|
|
13
|
|
|
test('Defining ArmUI.Accordion', () => { |
14
|
|
|
expect(ArmUI.Accordion).toBeDefined(); |
15
|
|
|
}); |
16
|
|
|
|
17
|
|
|
test('Defining ArmUI.Tabs', () => { |
18
|
|
|
expect(ArmUI.Tabs).toBeDefined(); |
19
|
|
|
}); |
20
|
|
|
|
21
|
|
|
test('Defining ArmUI.Popup', () => { |
22
|
|
|
expect(ArmUI.Popup).toBeDefined(); |
23
|
|
|
}); |
24
|
|
|
|
25
|
|
|
test('Defining ArmUI.SelectExtended', () => { |
26
|
|
|
expect(ArmUI.SelectExtended).toBeDefined(); |
27
|
|
|
}); |
28
|
|
|
|
29
|
|
|
test('Defining ArmUI.Dropdown', () => { |
30
|
|
|
expect(ArmUI.Dropdown).toBeDefined(); |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
test('Defining ArmUI.Lightbox', () => { |
34
|
|
|
expect(ArmUI.Lightbox).toBeDefined(); |
35
|
|
|
}); |
36
|
|
|
|
37
|
|
|
}); |
38
|
|
|
|
39
|
|
|
describe('Accordion testing', () => { |
40
|
|
|
|
41
|
|
|
//Default accordion markup |
42
|
|
|
|
43
|
|
|
document.body.innerHTML = ` |
44
|
|
|
<div class="accordion"> |
45
|
|
|
<div>Question1</div> |
46
|
|
|
<div>Answer1</div> |
47
|
|
|
</div> |
48
|
|
|
`; |
49
|
|
|
|
50
|
|
|
//Accordion initialization |
51
|
|
|
|
52
|
|
|
let accordion = new ArmUI.Accordion({ |
53
|
|
|
el: document.querySelectorAll('.accordion'), |
54
|
|
|
openOneCloseAll: true |
55
|
|
|
}); |
56
|
|
|
|
57
|
|
|
test('Accordion module should be defined', () => { |
58
|
|
|
expect(accordion).toBeDefined(); |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
test('Accordion should contain root selector', () => { |
62
|
|
|
expect(accordion.options.el).toBeDefined(); |
63
|
|
|
}); |
64
|
|
|
|
65
|
|
|
test('Accordion should contain openOneCloseAll function with "truthy" value', () => { |
66
|
|
|
expect(accordion.options.openOneCloseAll).toBe(true); |
67
|
|
|
}); |
68
|
|
|
|
69
|
|
|
}); |
70
|
|
|
|
71
|
|
|
describe('Tabs testing', () => { |
72
|
|
|
|
73
|
|
|
//Default tabs markup |
74
|
|
|
|
75
|
|
|
document.body.innerHTML = ` |
76
|
|
|
<ul class="tabs"> |
77
|
|
|
<li> |
78
|
|
|
<a href="" data-pane="pane-1">Link 1</a> |
79
|
|
|
</li> |
80
|
|
|
<li> |
81
|
|
|
<a href="" data-pane="pane-2">Link 2</a> |
82
|
|
|
</li> |
83
|
|
|
</ul> |
84
|
|
|
<div class="tab-pane" id="pane-1">Content 1</div> |
85
|
|
|
<div class="tab-pane" id="pane-2">Content 2</div> |
86
|
|
|
`; |
87
|
|
|
|
88
|
|
|
//Tabs initialization |
89
|
|
|
|
90
|
|
|
let tabs = new ArmUI.Tabs({ |
91
|
|
|
tabTogglers: document.querySelectorAll('.tabs a'), |
92
|
|
|
onLoad: function() {} |
93
|
|
|
}); |
94
|
|
|
|
95
|
|
|
test('Tabs module should be defined', () => { |
96
|
|
|
expect(tabs).toBeDefined(); |
97
|
|
|
}); |
98
|
|
|
|
99
|
|
|
test('Tabs should contain togglers option', () => { |
100
|
|
|
expect(tabs.options.tabTogglers).toBeDefined(); |
101
|
|
|
}); |
102
|
|
|
|
103
|
|
|
test('Tabs should contain onLoad function', () => { |
104
|
|
|
expect(tabs.options.onLoad).toBeDefined(); |
105
|
|
|
expect(tabs.options.onLoad).toBeInstanceOf(Function); |
106
|
|
|
}); |
107
|
|
|
|
108
|
|
|
}); |
109
|
|
|
|
110
|
|
|
describe('Popup testing', () => { |
111
|
|
|
|
112
|
|
|
//Default popup markup |
113
|
|
|
|
114
|
|
|
document.body.innerHTML = ` |
115
|
|
|
<div class="popup"> |
116
|
|
|
<div>Popup text</div> |
117
|
|
|
</div> |
118
|
|
|
<a href="#" class="j-popup">Show popup</a> |
119
|
|
|
`; |
120
|
|
|
|
121
|
|
|
//Popup initialization |
122
|
|
|
|
123
|
|
|
let popup = new ArmUI.Popup({ |
124
|
|
|
el: '.popup', |
125
|
|
|
openers: '.j-popup', |
126
|
|
|
closable: true, |
127
|
|
|
onLoad: function() {}, |
128
|
|
|
onOpen: function() {}, |
129
|
|
|
onClose: function() {} |
130
|
|
|
}); |
131
|
|
|
|
132
|
|
|
test('Popup module should be defined', () => { |
133
|
|
|
expect(popup).toBeDefined(); |
134
|
|
|
}); |
135
|
|
|
|
136
|
|
|
test('ArmUI.Popup should contain root selector', () => { |
137
|
|
|
expect(popup.options.el).toBeDefined(); |
138
|
|
|
}); |
139
|
|
|
|
140
|
|
|
test('Popup should contain "openers" option', () => { |
141
|
|
|
expect(popup.options.openers).toBeTruthy(); |
142
|
|
|
}); |
143
|
|
|
|
144
|
|
|
test('Popup should contain "closable" option', () => { |
145
|
|
|
expect(popup.options.closable).toBeTruthy(); |
146
|
|
|
}); |
147
|
|
|
|
148
|
|
|
test('Popup should contain "onLoad" function', () => { |
149
|
|
|
expect(popup.options.onLoad).toBeDefined(); |
150
|
|
|
expect(popup.options.onLoad).toBeInstanceOf(Function); |
151
|
|
|
}); |
152
|
|
|
|
153
|
|
|
test('Popup should contain "onOpen" function', () => { |
154
|
|
|
expect(popup.options.onOpen).toBeDefined(); |
155
|
|
|
expect(popup.options.onOpen).toBeInstanceOf(Function); |
156
|
|
|
}); |
157
|
|
|
|
158
|
|
|
test('Popup should contain "onClose" function', () => { |
159
|
|
|
expect(popup.options.onClose).toBeDefined(); |
160
|
|
|
expect(popup.options.onClose).toBeInstanceOf(Function); |
161
|
|
|
}); |
162
|
|
|
|
163
|
|
|
}); |
164
|
|
|
|
165
|
|
|
describe('SelectExtended testing', () => { |
166
|
|
|
|
167
|
|
|
//Default select markup |
168
|
|
|
|
169
|
|
|
document.body.innerHTML = ` |
170
|
|
|
<select class="select-default" data-placeholder="Выберите опцию"> |
171
|
|
|
<option value="1">1</option> |
172
|
|
|
<option value="2">2</option> |
173
|
|
|
</select> |
174
|
|
|
`; |
175
|
|
|
|
176
|
|
|
//Select initialization |
177
|
|
|
|
178
|
|
|
let select = new ArmUI.SelectExtended('.select-default', { |
179
|
|
|
containerClass: 'additional-class', |
180
|
|
|
multiSelect: false, |
181
|
|
|
multiSelectedText: 'Выбрано', |
182
|
|
|
onChange: function() {} |
183
|
|
|
}); |
184
|
|
|
|
185
|
|
|
test('SelectExtended module should be defined', () => { |
186
|
|
|
expect(select).toBeDefined(); |
187
|
|
|
}); |
188
|
|
|
|
189
|
|
|
test('SelectExtended should contain root selector', () => { |
190
|
|
|
expect(select.$el).toBeDefined(); |
191
|
|
|
}); |
192
|
|
|
|
193
|
|
|
test('SelectExtended toBe multiselected', () => { |
194
|
|
|
expect(select.options.multiSelect).toBeFalsy(); |
195
|
|
|
}); |
196
|
|
|
|
197
|
|
|
test('SelectExtended should have class wrapper', () => { |
198
|
|
|
expect(select.options.containerClass).toBeDefined(); |
199
|
|
|
}); |
200
|
|
|
|
201
|
|
|
test('SelectExtended should have "onChange" function', () => { |
202
|
|
|
expect(select.options.onChange).toBeDefined(); |
203
|
|
|
expect(select.options.onChange).toBeInstanceOf(Function); |
204
|
|
|
}); |
205
|
|
|
|
206
|
|
|
}); |
207
|
|
|
|
208
|
|
|
describe('Dropdown testing', () => { |
209
|
|
|
|
210
|
|
|
//Default dropdown markup |
211
|
|
|
|
212
|
|
|
document.body.innerHTML = ` |
213
|
|
|
<div id="dropdown-lang" class="dropdown"> |
214
|
|
|
<a href="#" class="toggler">Some text</a> |
215
|
|
|
<ul class="dropdown__content"> |
216
|
|
|
<li> |
217
|
|
|
<a href="">111</a> |
218
|
|
|
</li> |
219
|
|
|
</ul> |
220
|
|
|
</div> |
221
|
|
|
`; |
222
|
|
|
|
223
|
|
|
//Dropdown initialization |
224
|
|
|
|
225
|
|
|
let dropdown = new ArmUI.Dropdown('#dropdown-lang', { |
226
|
|
|
togglers: document.querySelectorAll('.toggler'), |
227
|
|
|
bodyClose: true, |
228
|
|
|
opened: false, |
229
|
|
|
onOpen: function() {}, |
230
|
|
|
onClose: function() {} |
231
|
|
|
}); |
232
|
|
|
|
233
|
|
|
test('Dropdown module should be defined', () => { |
234
|
|
|
expect(dropdown).toBeDefined(); |
235
|
|
|
}); |
236
|
|
|
|
237
|
|
|
test('Dropdown should contain root selector', () => { |
238
|
|
|
expect(dropdown.$el).toBeDefined(); |
239
|
|
|
}); |
240
|
|
|
|
241
|
|
|
test('Dropdown should have "togglers" options', () => { |
242
|
|
|
expect(dropdown.options.togglers).toBeTruthy(); |
243
|
|
|
}); |
244
|
|
|
|
245
|
|
|
test('Dropdown should have "bodyClose" options', () => { |
246
|
|
|
expect(dropdown.options.bodyClose).toBeTruthy(); |
247
|
|
|
}); |
248
|
|
|
|
249
|
|
|
test('Dropdown should have "opened" options', () => { |
250
|
|
|
expect(dropdown.options.opened).toBeFalsy(); |
251
|
|
|
}); |
252
|
|
|
|
253
|
|
|
test('Dropdown should have "onOpen" function', () => { |
254
|
|
|
expect(dropdown.options.onOpen).toBeDefined(); |
255
|
|
|
expect(dropdown.options.onOpen).toBeInstanceOf(Function); |
256
|
|
|
}); |
257
|
|
|
|
258
|
|
|
test('Dropdown should have "onClose" function', () => { |
259
|
|
|
expect(dropdown.options.onClose).toBeDefined(); |
260
|
|
|
expect(dropdown.options.onClose).toBeInstanceOf(Function); |
261
|
|
|
}); |
262
|
|
|
}); |