@osimatic/helpers-js 1.4.24 → 1.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +2 -1
- package/chartjs.js +1 -1
- package/date_time.js +25 -16
- package/draw.js +3 -2
- package/duration.js +176 -130
- package/event_bus.js +2 -2
- package/file.js +20 -5
- package/form_helper.js +1 -1
- package/google_charts.js +2 -1
- package/http_client.js +2 -0
- package/jwt.js +18 -6
- package/location.js +5 -1
- package/media.js +7 -7
- package/multi_files_input.js +3 -1
- package/number.js +2 -3
- package/package.json +4 -2
- package/paging.js +2 -2
- package/social_network.js +5 -0
- package/string.js +11 -2
- package/tests/__mocks__/socket.io-client.js +13 -0
- package/tests/chartjs.test.js +273 -0
- package/tests/count_down.test.js +580 -0
- package/tests/date_time/DatePeriod.test.js +179 -0
- package/tests/date_time/DateTime.test.js +492 -0
- package/tests/date_time/SqlDate.test.js +205 -0
- package/tests/date_time/SqlDateTime.test.js +326 -0
- package/tests/date_time/SqlTime.test.js +162 -0
- package/tests/date_time/TimestampUnix.test.js +262 -0
- package/tests/details_sub_array.test.js +367 -0
- package/tests/draw.test.js +271 -0
- package/tests/duration.test.js +365 -0
- package/tests/event_bus.test.js +268 -0
- package/tests/file.test.js +568 -0
- package/tests/flash_message.test.js +297 -0
- package/tests/form_date.test.js +1559 -0
- package/tests/form_helper.test.js +1065 -0
- package/tests/google_charts.test.js +768 -0
- package/tests/google_maps.test.js +655 -0
- package/tests/google_recaptcha.test.js +441 -0
- package/tests/http_client.test.js +570 -0
- package/tests/import_from_csv.test.js +797 -0
- package/tests/jwt.test.js +804 -0
- package/tests/list_box.test.js +255 -0
- package/tests/location.test.js +86 -0
- package/tests/media.test.js +473 -0
- package/tests/multi_files_input.test.js +1015 -0
- package/tests/multiple_action_in_table.test.js +477 -0
- package/tests/network.test.js +489 -0
- package/tests/number.test.js +448 -0
- package/tests/open_street_map.test.js +388 -0
- package/tests/paging.test.js +646 -0
- package/tests/select_all.test.js +360 -0
- package/tests/shopping_cart.test.js +355 -0
- package/tests/social_network.test.js +333 -0
- package/tests/sortable_list.test.js +602 -0
- package/tests/string.test.js +489 -0
- package/tests/user.test.js +204 -0
- package/tests/util.test.js +99 -0
- package/tests/visitor.test.js +508 -0
- package/tests/web_rtc.test.js +458 -0
- package/tests/web_socket.test.js +538 -0
- package/visitor.js +2 -2
- package/tmpclaude-0fa4-cwd +0 -1
- package/tmpclaude-104f-cwd +0 -1
- package/tmpclaude-1468-cwd +0 -1
- package/tmpclaude-324b-cwd +0 -1
- package/tmpclaude-35d3-cwd +0 -1
- package/tmpclaude-4aa8-cwd +0 -1
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
const { MultipleActionInTable, MultipleActionInDivList } = require('../multiple_action_in_table');
|
|
5
|
+
|
|
6
|
+
describe('MultipleActionInTable', () => {
|
|
7
|
+
let mockTable;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
// Mock jQuery
|
|
11
|
+
global.$ = jest.fn((selector) => {
|
|
12
|
+
if (typeof selector === 'string') {
|
|
13
|
+
if (selector.includes('<th') || selector.includes('<td') || selector.includes('<p>') || selector.includes('<img') || selector.includes('<span') || selector.includes('<div')) {
|
|
14
|
+
// Creating new element
|
|
15
|
+
return {
|
|
16
|
+
addClass: jest.fn().mockReturnThis(),
|
|
17
|
+
removeClass: jest.fn().mockReturnThis(),
|
|
18
|
+
hasClass: jest.fn(() => false),
|
|
19
|
+
find: jest.fn(() => ({ length: 0 })),
|
|
20
|
+
prepend: jest.fn().mockReturnThis(),
|
|
21
|
+
append: jest.fn().mockReturnThis(),
|
|
22
|
+
after: jest.fn().mockReturnThis(),
|
|
23
|
+
remove: jest.fn().mockReturnThis()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
find: jest.fn(() => ({ length: 0 })),
|
|
28
|
+
hasClass: jest.fn(() => false),
|
|
29
|
+
addClass: jest.fn().mockReturnThis(),
|
|
30
|
+
removeClass: jest.fn().mockReturnThis()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Handle element wrapping
|
|
34
|
+
return {
|
|
35
|
+
find: jest.fn(() => ({ length: 0 })),
|
|
36
|
+
hasClass: jest.fn(() => false),
|
|
37
|
+
closest: jest.fn(() => mockTable),
|
|
38
|
+
addClass: jest.fn().mockReturnThis(),
|
|
39
|
+
removeClass: jest.fn().mockReturnThis(),
|
|
40
|
+
data: jest.fn()
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Mock ROOT_PATH and DOSSIER_IMAGES
|
|
45
|
+
global.ROOT_PATH = '/';
|
|
46
|
+
global.DOSSIER_IMAGES = 'images/';
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
jest.clearAllMocks();
|
|
51
|
+
delete global.$;
|
|
52
|
+
delete global.ROOT_PATH;
|
|
53
|
+
delete global.DOSSIER_IMAGES;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('getDivBtn', () => {
|
|
57
|
+
test('should return button div when found as next sibling', () => {
|
|
58
|
+
const mockButtonDiv = {
|
|
59
|
+
hasClass: jest.fn((className) => className === 'action_multiple_buttons')
|
|
60
|
+
};
|
|
61
|
+
mockTable = {
|
|
62
|
+
parent: jest.fn(() => ({
|
|
63
|
+
next: jest.fn(() => mockButtonDiv)
|
|
64
|
+
}))
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const result = MultipleActionInTable.getDivBtn(mockTable);
|
|
68
|
+
|
|
69
|
+
expect(result).toBe(mockButtonDiv);
|
|
70
|
+
expect(mockButtonDiv.hasClass).toHaveBeenCalledWith('action_multiple_buttons');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('should return button div when found in nested structure', () => {
|
|
74
|
+
const mockButtonDiv = {
|
|
75
|
+
hasClass: jest.fn((className) => className === 'action_multiple_buttons')
|
|
76
|
+
};
|
|
77
|
+
const notButtonDiv = {
|
|
78
|
+
hasClass: jest.fn(() => false)
|
|
79
|
+
};
|
|
80
|
+
mockTable = {
|
|
81
|
+
parent: jest.fn(() => ({
|
|
82
|
+
next: jest.fn(() => notButtonDiv),
|
|
83
|
+
parent: jest.fn(() => ({
|
|
84
|
+
parent: jest.fn(() => ({
|
|
85
|
+
parent: jest.fn(() => ({
|
|
86
|
+
next: jest.fn(() => mockButtonDiv)
|
|
87
|
+
}))
|
|
88
|
+
}))
|
|
89
|
+
}))
|
|
90
|
+
}))
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const result = MultipleActionInTable.getDivBtn(mockTable);
|
|
94
|
+
|
|
95
|
+
expect(result).toBe(mockButtonDiv);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('should return null when button div not found', () => {
|
|
99
|
+
const notButtonDiv = {
|
|
100
|
+
hasClass: jest.fn(() => false)
|
|
101
|
+
};
|
|
102
|
+
mockTable = {
|
|
103
|
+
parent: jest.fn(() => ({
|
|
104
|
+
next: jest.fn(() => notButtonDiv),
|
|
105
|
+
parent: jest.fn(() => ({
|
|
106
|
+
parent: jest.fn(() => ({
|
|
107
|
+
parent: jest.fn(() => ({
|
|
108
|
+
next: jest.fn(() => notButtonDiv)
|
|
109
|
+
}))
|
|
110
|
+
}))
|
|
111
|
+
}))
|
|
112
|
+
}))
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const result = MultipleActionInTable.getDivBtn(mockTable);
|
|
116
|
+
|
|
117
|
+
expect(result).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('updateCheckbox', () => {
|
|
122
|
+
test('should hide select-all checkbox when no checkboxes exist', () => {
|
|
123
|
+
const mockCheckboxSelectAll = {
|
|
124
|
+
addClass: jest.fn(),
|
|
125
|
+
removeClass: jest.fn()
|
|
126
|
+
};
|
|
127
|
+
const mockButtonDiv = {
|
|
128
|
+
hasClass: jest.fn(() => false)
|
|
129
|
+
};
|
|
130
|
+
mockTable = {
|
|
131
|
+
find: jest.fn((selector) => {
|
|
132
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
133
|
+
return { length: 0 };
|
|
134
|
+
}
|
|
135
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
136
|
+
return { length: 0 };
|
|
137
|
+
}
|
|
138
|
+
if (selector === 'thead tr th input.action_multiple_check_all') {
|
|
139
|
+
return mockCheckboxSelectAll;
|
|
140
|
+
}
|
|
141
|
+
return { length: 0 };
|
|
142
|
+
}),
|
|
143
|
+
parent: jest.fn(() => ({
|
|
144
|
+
next: jest.fn(() => mockButtonDiv),
|
|
145
|
+
parent: jest.fn(() => ({
|
|
146
|
+
parent: jest.fn(() => ({
|
|
147
|
+
parent: jest.fn(() => ({
|
|
148
|
+
next: jest.fn(() => mockButtonDiv)
|
|
149
|
+
}))
|
|
150
|
+
}))
|
|
151
|
+
}))
|
|
152
|
+
}))
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
MultipleActionInTable.updateCheckbox(mockTable);
|
|
156
|
+
|
|
157
|
+
expect(mockCheckboxSelectAll.addClass).toHaveBeenCalledWith('hide');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('should check select-all checkbox when all checkboxes are checked', () => {
|
|
161
|
+
const mockCheckboxSelectAll = {
|
|
162
|
+
addClass: jest.fn(),
|
|
163
|
+
removeClass: jest.fn(),
|
|
164
|
+
prop: jest.fn()
|
|
165
|
+
};
|
|
166
|
+
const mockButtonDiv = {
|
|
167
|
+
hasClass: jest.fn(() => false)
|
|
168
|
+
};
|
|
169
|
+
mockTable = {
|
|
170
|
+
find: jest.fn((selector) => {
|
|
171
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
172
|
+
return { length: 3 };
|
|
173
|
+
}
|
|
174
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
175
|
+
return { length: 3 };
|
|
176
|
+
}
|
|
177
|
+
if (selector === 'thead tr th input.action_multiple_check_all') {
|
|
178
|
+
return mockCheckboxSelectAll;
|
|
179
|
+
}
|
|
180
|
+
return { length: 0 };
|
|
181
|
+
}),
|
|
182
|
+
parent: jest.fn(() => ({
|
|
183
|
+
next: jest.fn(() => mockButtonDiv),
|
|
184
|
+
parent: jest.fn(() => ({
|
|
185
|
+
parent: jest.fn(() => ({
|
|
186
|
+
parent: jest.fn(() => ({
|
|
187
|
+
next: jest.fn(() => mockButtonDiv)
|
|
188
|
+
}))
|
|
189
|
+
}))
|
|
190
|
+
}))
|
|
191
|
+
}))
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
MultipleActionInTable.updateCheckbox(mockTable);
|
|
195
|
+
|
|
196
|
+
expect(mockCheckboxSelectAll.removeClass).toHaveBeenCalledWith('hide');
|
|
197
|
+
expect(mockCheckboxSelectAll.prop).toHaveBeenCalledWith('checked', true);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('should uncheck select-all checkbox when not all checkboxes are checked', () => {
|
|
201
|
+
const mockCheckboxSelectAll = {
|
|
202
|
+
addClass: jest.fn(),
|
|
203
|
+
removeClass: jest.fn(),
|
|
204
|
+
prop: jest.fn()
|
|
205
|
+
};
|
|
206
|
+
const mockButtonDiv = {
|
|
207
|
+
hasClass: jest.fn(() => false)
|
|
208
|
+
};
|
|
209
|
+
mockTable = {
|
|
210
|
+
find: jest.fn((selector) => {
|
|
211
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
212
|
+
return { length: 5 };
|
|
213
|
+
}
|
|
214
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
215
|
+
return { length: 2 };
|
|
216
|
+
}
|
|
217
|
+
if (selector === 'thead tr th input.action_multiple_check_all') {
|
|
218
|
+
return mockCheckboxSelectAll;
|
|
219
|
+
}
|
|
220
|
+
return { length: 0 };
|
|
221
|
+
}),
|
|
222
|
+
parent: jest.fn(() => ({
|
|
223
|
+
next: jest.fn(() => mockButtonDiv),
|
|
224
|
+
parent: jest.fn(() => ({
|
|
225
|
+
parent: jest.fn(() => ({
|
|
226
|
+
parent: jest.fn(() => ({
|
|
227
|
+
next: jest.fn(() => mockButtonDiv)
|
|
228
|
+
}))
|
|
229
|
+
}))
|
|
230
|
+
}))
|
|
231
|
+
}))
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
MultipleActionInTable.updateCheckbox(mockTable);
|
|
235
|
+
|
|
236
|
+
expect(mockCheckboxSelectAll.removeClass).toHaveBeenCalledWith('hide');
|
|
237
|
+
expect(mockCheckboxSelectAll.prop).toHaveBeenCalledWith('checked', false);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('showButtonsAction', () => {
|
|
242
|
+
test('should return early when button div is null', () => {
|
|
243
|
+
mockTable = {
|
|
244
|
+
parent: jest.fn(() => ({
|
|
245
|
+
next: jest.fn(() => ({ hasClass: jest.fn(() => false) })),
|
|
246
|
+
parent: jest.fn(() => ({
|
|
247
|
+
parent: jest.fn(() => ({
|
|
248
|
+
parent: jest.fn(() => ({
|
|
249
|
+
next: jest.fn(() => ({ hasClass: jest.fn(() => false) }))
|
|
250
|
+
}))
|
|
251
|
+
}))
|
|
252
|
+
}))
|
|
253
|
+
})),
|
|
254
|
+
find: jest.fn(() => ({ length: 0 }))
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
expect(() => {
|
|
258
|
+
MultipleActionInTable.showButtonsAction(mockTable);
|
|
259
|
+
}).not.toThrow();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('should show button div when items are checked', () => {
|
|
263
|
+
const mockButtonDiv = {
|
|
264
|
+
hasClass: jest.fn(() => true),
|
|
265
|
+
is: jest.fn((selector) => selector === ':hidden'),
|
|
266
|
+
removeClass: jest.fn(),
|
|
267
|
+
addClass: jest.fn(),
|
|
268
|
+
find: jest.fn(() => ({
|
|
269
|
+
length: 1,
|
|
270
|
+
remove: jest.fn(),
|
|
271
|
+
after: jest.fn()
|
|
272
|
+
}))
|
|
273
|
+
};
|
|
274
|
+
mockTable = {
|
|
275
|
+
parent: jest.fn(() => ({
|
|
276
|
+
next: jest.fn(() => mockButtonDiv)
|
|
277
|
+
})),
|
|
278
|
+
find: jest.fn((selector) => {
|
|
279
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
280
|
+
return { length: 2 };
|
|
281
|
+
}
|
|
282
|
+
return { length: 0 };
|
|
283
|
+
}),
|
|
284
|
+
is: jest.fn(() => false)
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
MultipleActionInTable.showButtonsAction(mockTable);
|
|
288
|
+
|
|
289
|
+
expect(mockButtonDiv.removeClass).toHaveBeenCalledWith('hide');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('should hide button div when no items are checked', () => {
|
|
293
|
+
const mockButtonDiv = {
|
|
294
|
+
hasClass: jest.fn(() => true),
|
|
295
|
+
is: jest.fn((selector) => selector === ':visible'),
|
|
296
|
+
removeClass: jest.fn(),
|
|
297
|
+
addClass: jest.fn(),
|
|
298
|
+
find: jest.fn((selector) => {
|
|
299
|
+
if (selector === 'span.no_button') {
|
|
300
|
+
return { remove: jest.fn() };
|
|
301
|
+
}
|
|
302
|
+
if (selector === 'button:visible, a:visible') {
|
|
303
|
+
return { length: 0 };
|
|
304
|
+
}
|
|
305
|
+
if (selector === 'img') {
|
|
306
|
+
return { after: jest.fn() };
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
length: 0,
|
|
310
|
+
remove: jest.fn()
|
|
311
|
+
};
|
|
312
|
+
})
|
|
313
|
+
};
|
|
314
|
+
mockTable = {
|
|
315
|
+
parent: jest.fn(() => ({
|
|
316
|
+
next: jest.fn(() => mockButtonDiv)
|
|
317
|
+
})),
|
|
318
|
+
find: jest.fn(() => ({ length: 0 })),
|
|
319
|
+
is: jest.fn(() => false)
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
MultipleActionInTable.showButtonsAction(mockTable);
|
|
323
|
+
|
|
324
|
+
expect(mockButtonDiv.addClass).toHaveBeenCalledWith('hide');
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe('MultipleActionInDivList', () => {
|
|
330
|
+
let mockContentDiv;
|
|
331
|
+
|
|
332
|
+
beforeEach(() => {
|
|
333
|
+
// Mock jQuery
|
|
334
|
+
global.$ = jest.fn((selector) => {
|
|
335
|
+
if (typeof selector === 'string' && (selector.includes('<') || selector.includes('img'))) {
|
|
336
|
+
return {
|
|
337
|
+
addClass: jest.fn().mockReturnThis(),
|
|
338
|
+
removeClass: jest.fn().mockReturnThis(),
|
|
339
|
+
prepend: jest.fn().mockReturnThis(),
|
|
340
|
+
append: jest.fn().mockReturnThis()
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
find: jest.fn(() => ({ length: 0 })),
|
|
345
|
+
hasClass: jest.fn(() => false)
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
global.ROOT_PATH = '/';
|
|
350
|
+
global.DOSSIER_IMAGES = 'images/';
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
afterEach(() => {
|
|
354
|
+
jest.clearAllMocks();
|
|
355
|
+
delete global.$;
|
|
356
|
+
delete global.ROOT_PATH;
|
|
357
|
+
delete global.DOSSIER_IMAGES;
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe('getButtonsDiv', () => {
|
|
361
|
+
test('should return buttons div when found', () => {
|
|
362
|
+
const mockButtonsDiv = {
|
|
363
|
+
hasClass: jest.fn(() => true)
|
|
364
|
+
};
|
|
365
|
+
mockContentDiv = {
|
|
366
|
+
next: jest.fn(() => mockButtonsDiv)
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const result = MultipleActionInDivList.getButtonsDiv(mockContentDiv);
|
|
370
|
+
|
|
371
|
+
expect(result).toBe(mockButtonsDiv);
|
|
372
|
+
expect(mockButtonsDiv.hasClass).toHaveBeenCalledWith('action_multiple_buttons');
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test('should return null when buttons div not found', () => {
|
|
376
|
+
const notButtonsDiv = {
|
|
377
|
+
hasClass: jest.fn(() => false)
|
|
378
|
+
};
|
|
379
|
+
mockContentDiv = {
|
|
380
|
+
next: jest.fn(() => notButtonsDiv)
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const result = MultipleActionInDivList.getButtonsDiv(mockContentDiv);
|
|
384
|
+
|
|
385
|
+
expect(result).toBeNull();
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
describe('updateCheckbox', () => {
|
|
390
|
+
test('should hide select-all checkbox when no checkboxes exist', () => {
|
|
391
|
+
const mockCheckboxSelectAll = {
|
|
392
|
+
addClass: jest.fn(),
|
|
393
|
+
removeClass: jest.fn()
|
|
394
|
+
};
|
|
395
|
+
const mockButtonsDiv = {
|
|
396
|
+
hasClass: jest.fn(() => false)
|
|
397
|
+
};
|
|
398
|
+
mockContentDiv = {
|
|
399
|
+
find: jest.fn((selector) => {
|
|
400
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
401
|
+
return { length: 0 };
|
|
402
|
+
}
|
|
403
|
+
if (selector === 'input.action_multiple_check_all') {
|
|
404
|
+
return mockCheckboxSelectAll;
|
|
405
|
+
}
|
|
406
|
+
return { length: 0 };
|
|
407
|
+
}),
|
|
408
|
+
next: jest.fn(() => mockButtonsDiv)
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
MultipleActionInDivList.updateCheckbox(mockContentDiv);
|
|
412
|
+
|
|
413
|
+
expect(mockCheckboxSelectAll.addClass).toHaveBeenCalledWith('hide');
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test('should check select-all checkbox when all checkboxes are checked', () => {
|
|
417
|
+
const mockCheckboxSelectAll = {
|
|
418
|
+
addClass: jest.fn(),
|
|
419
|
+
removeClass: jest.fn(),
|
|
420
|
+
prop: jest.fn()
|
|
421
|
+
};
|
|
422
|
+
const mockButtonsDiv = {
|
|
423
|
+
hasClass: jest.fn(() => false)
|
|
424
|
+
};
|
|
425
|
+
mockContentDiv = {
|
|
426
|
+
find: jest.fn((selector) => {
|
|
427
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
428
|
+
return { length: 4 };
|
|
429
|
+
}
|
|
430
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
431
|
+
return { length: 4 };
|
|
432
|
+
}
|
|
433
|
+
if (selector === 'input.action_multiple_check_all') {
|
|
434
|
+
return mockCheckboxSelectAll;
|
|
435
|
+
}
|
|
436
|
+
return { length: 0 };
|
|
437
|
+
}),
|
|
438
|
+
next: jest.fn(() => mockButtonsDiv)
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
MultipleActionInDivList.updateCheckbox(mockContentDiv);
|
|
442
|
+
|
|
443
|
+
expect(mockCheckboxSelectAll.removeClass).toHaveBeenCalledWith('hide');
|
|
444
|
+
expect(mockCheckboxSelectAll.prop).toHaveBeenCalledWith('checked', true);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
test('should uncheck select-all checkbox when not all checkboxes are checked', () => {
|
|
448
|
+
const mockCheckboxSelectAll = {
|
|
449
|
+
addClass: jest.fn(),
|
|
450
|
+
removeClass: jest.fn(),
|
|
451
|
+
prop: jest.fn()
|
|
452
|
+
};
|
|
453
|
+
const mockButtonsDiv = {
|
|
454
|
+
hasClass: jest.fn(() => false)
|
|
455
|
+
};
|
|
456
|
+
mockContentDiv = {
|
|
457
|
+
find: jest.fn((selector) => {
|
|
458
|
+
if (selector === 'input.action_multiple_checkbox') {
|
|
459
|
+
return { length: 4 };
|
|
460
|
+
}
|
|
461
|
+
if (selector === 'input.action_multiple_checkbox:checked') {
|
|
462
|
+
return { length: 1 };
|
|
463
|
+
}
|
|
464
|
+
if (selector === 'input.action_multiple_check_all') {
|
|
465
|
+
return mockCheckboxSelectAll;
|
|
466
|
+
}
|
|
467
|
+
return { length: 0 };
|
|
468
|
+
}),
|
|
469
|
+
next: jest.fn(() => mockButtonsDiv)
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
MultipleActionInDivList.updateCheckbox(mockContentDiv);
|
|
473
|
+
|
|
474
|
+
expect(mockCheckboxSelectAll.prop).toHaveBeenCalledWith('checked', false);
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
});
|