govuk_frontend_toolkit 1.7.0 → 2.0.0
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.
@@ -2,7 +2,8 @@ describe("selection-buttons", function () {
|
|
2
2
|
var $radioButtons,
|
3
3
|
$radioLabels,
|
4
4
|
$checkboxButtons,
|
5
|
-
$checkboxLabels
|
5
|
+
$checkboxLabels,
|
6
|
+
buttonsInstance;
|
6
7
|
|
7
8
|
beforeEach(function () {
|
8
9
|
$radioLabels = $(
|
@@ -35,309 +36,730 @@ describe("selection-buttons", function () {
|
|
35
36
|
);
|
36
37
|
$radioButtons = $radioLabels.find('input');
|
37
38
|
$checkboxButtons = $checkboxLabels.find('input');
|
38
|
-
$(
|
39
|
-
$(
|
39
|
+
$radioForm = $('<form action="" method="post" />');
|
40
|
+
$checkboxForm = $('<form action="" method="post" />');
|
41
|
+
$content = $('<div id="content" />');
|
42
|
+
$radioForm.append($radioLabels);
|
43
|
+
$checkboxForm.append($checkboxLabels);
|
44
|
+
$content.append($radioForm);
|
45
|
+
$content.append($checkboxForm);
|
46
|
+
$(document.body).append($content);
|
40
47
|
});
|
41
48
|
|
42
49
|
afterEach(function () {
|
43
|
-
$
|
44
|
-
$checkboxLabels.remove();
|
50
|
+
$content.remove();
|
45
51
|
});
|
46
52
|
|
47
|
-
describe("
|
48
|
-
|
49
|
-
|
53
|
+
describe("When buttonsInstance = new GOVUK.SelectionButtons is called with a jQuery object", function () {
|
54
|
+
describe("When that object contains only radio inputs", function () {
|
55
|
+
describe("At the point it is called", function () {
|
56
|
+
it("Should do nothing if no radios are checked", function () {
|
57
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
58
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(false);
|
59
|
+
expect($radioLabels.eq(1).hasClass('selected')).toBe(false);
|
60
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
61
|
+
});
|
50
62
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
63
|
+
it("Should mark checked radios with the selected class", function () {
|
64
|
+
$radioButtons.eq(0).attr('checked', true);
|
65
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
66
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
67
|
+
});
|
56
68
|
|
57
|
-
|
58
|
-
|
69
|
+
it("Should mark checked radios with the custom selected class if given", function () {
|
70
|
+
$radioButtons.eq(0).attr('checked', true);
|
71
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons, { 'selectedClass' : 'selectable-selected' });
|
72
|
+
expect($radioLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
73
|
+
});
|
74
|
+
});
|
59
75
|
|
60
|
-
|
61
|
-
|
76
|
+
describe("If one of those radios receives focus", function () {
|
77
|
+
it("Should add the focused class to that radio", function () {
|
78
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
79
|
+
$radioButtons.eq(0).focus();
|
80
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
81
|
+
});
|
62
82
|
|
63
|
-
|
64
|
-
|
83
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
84
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons, { 'focusedClass' : 'selectable-focused' });
|
85
|
+
$radioButtons.eq(0).focus();
|
86
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
87
|
+
});
|
88
|
+
});
|
65
89
|
|
66
|
-
|
67
|
-
|
90
|
+
describe("If one of those radios loses focus", function () {
|
91
|
+
it("Should remove the focused class from that radio", function () {
|
92
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
93
|
+
$radioButtons.eq(0).focus();
|
94
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
95
|
+
$radioButtons.eq(0).blur();
|
96
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(false);
|
97
|
+
});
|
68
98
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
99
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
100
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons, { 'focusedClass' : 'selectable-focused' });
|
101
|
+
$radioButtons.eq(0).focus();
|
102
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
103
|
+
$radioButtons.eq(0).blur();
|
104
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
105
|
+
});
|
106
|
+
});
|
107
|
+
|
108
|
+
describe("If one of those radios is clicked", function () {
|
109
|
+
it("Should mark that radio with the selected class", function () {
|
110
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
111
|
+
$radioButtons.eq(0)
|
112
|
+
.attr('checked', true)
|
113
|
+
.trigger('click');
|
114
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
115
|
+
});
|
76
116
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
117
|
+
it("Should remove the selected class from all other radios", function () {
|
118
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
119
|
+
$radioLabels.eq(1).addClass('selected');
|
120
|
+
$radioButtons.eq(0)
|
121
|
+
.attr('checked', true)
|
122
|
+
.trigger('click');
|
123
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
124
|
+
});
|
82
125
|
});
|
83
126
|
});
|
84
127
|
|
85
|
-
describe("
|
86
|
-
|
87
|
-
|
128
|
+
describe("When that object contains only checkbox inputs", function () {
|
129
|
+
describe("At the point it is called", function () {
|
130
|
+
it("Should do nothing if no checkboxes are checked", function () {
|
131
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
132
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(false);
|
133
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(false);
|
134
|
+
expect($checkboxLabels.eq(2).hasClass('selected')).toBe(false);
|
135
|
+
});
|
88
136
|
|
89
|
-
|
90
|
-
|
91
|
-
|
137
|
+
it("Should mark checked checkboxes with the selected class", function () {
|
138
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
139
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
140
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
141
|
+
});
|
142
|
+
|
143
|
+
it("Should mark all checked checkboxes with the selected class if there are more than one", function () {
|
144
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
145
|
+
$checkboxButtons.eq(1).attr('checked', true);
|
146
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
147
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
148
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(true);
|
149
|
+
});
|
150
|
+
|
151
|
+
it("Should mark checked checkboxes with the custom selected class if given", function () {
|
152
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
153
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons, { 'selectedClass' : 'selectable-selected' });
|
154
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
155
|
+
});
|
92
156
|
});
|
93
|
-
});
|
94
157
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
158
|
+
describe("If one of those checkboxes receives focus", function () {
|
159
|
+
it("Should add the focused class to that checkbox", function () {
|
160
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
161
|
+
$checkboxButtons.eq(0).focus();
|
162
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
163
|
+
});
|
164
|
+
|
165
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
166
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons, { 'focusedClass' : 'selectable-focused' });
|
167
|
+
$checkboxButtons.eq(0).focus();
|
168
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
169
|
+
});
|
170
|
+
});
|
171
|
+
|
172
|
+
describe("If one of those checkboxes loses focus", function () {
|
173
|
+
it("Should add the focused class to that checkbox", function () {
|
174
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
175
|
+
$checkboxButtons.eq(0).focus();
|
176
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
177
|
+
$checkboxButtons.eq(0).blur();
|
178
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(false);
|
179
|
+
});
|
180
|
+
|
181
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
182
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons, { 'focusedClass' : 'selectable-focused' });
|
183
|
+
$checkboxButtons.eq(0).focus();
|
184
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
185
|
+
$checkboxButtons.eq(0).blur();
|
186
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
187
|
+
});
|
188
|
+
});
|
189
|
+
|
190
|
+
describe("If one of those checkboxes is clicked", function () {
|
191
|
+
it("Should add the selected class to that checkbox", function () {
|
192
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons);
|
193
|
+
$checkboxButtons.eq(0)
|
194
|
+
.attr('checked', true)
|
195
|
+
.trigger('click');
|
196
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
197
|
+
});
|
198
|
+
|
199
|
+
it("Should add the selected class to that checkbox", function () {
|
200
|
+
buttonsInstance = new GOVUK.SelectionButtons($checkboxButtons, { 'selectedClass' : 'selectable-selected' });
|
201
|
+
$checkboxButtons.eq(0)
|
202
|
+
.attr('checked', true)
|
203
|
+
.trigger('click');
|
204
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
133
205
|
});
|
134
|
-
spyOn(radioButtonsMock, 'markSelected');
|
135
|
-
radioButtonsMock.$elms.eq(0).attr('checked', true);
|
136
|
-
GOVUK.RadioButtons.prototype.bindEvents.call(radioButtonsMock);
|
137
|
-
callback({ 'target' : radioButtonsMock.$elms[0] });
|
138
|
-
expect(radioButtonsMock.markSelected).toHaveBeenCalled();
|
139
206
|
});
|
140
207
|
});
|
141
208
|
|
142
|
-
describe("
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
209
|
+
describe("When that object contains a mixture of checkbox and radio inputs", function () {
|
210
|
+
var $mixedButtons;
|
211
|
+
|
212
|
+
beforeEach(function () {
|
213
|
+
$mixedButtons = $checkboxButtons.add($radioButtons);
|
214
|
+
});
|
215
|
+
|
216
|
+
describe("At the point it is called", function () {
|
217
|
+
it("Should do nothing if no checkboxes or radios are checked", function () {
|
218
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
219
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(false);
|
220
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(false);
|
221
|
+
expect($checkboxLabels.eq(2).hasClass('selected')).toBe(false);
|
222
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(false);
|
223
|
+
expect($radioLabels.eq(1).hasClass('selected')).toBe(false);
|
224
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
225
|
+
});
|
226
|
+
|
227
|
+
it("Should mark checked checkboxes or radios with the selected class", function () {
|
228
|
+
$mixedButtons.eq(0).attr('checked', true);
|
229
|
+
$mixedButtons.eq(3).attr('checked', true);
|
230
|
+
|
231
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
232
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
233
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
234
|
+
});
|
235
|
+
|
236
|
+
it("Should mark checked checkboxes or radios with the custom selected class if given", function () {
|
237
|
+
$mixedButtons.eq(0).attr('checked', true);
|
238
|
+
$mixedButtons.eq(3).attr('checked', true);
|
151
239
|
|
152
|
-
|
153
|
-
|
240
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'selectedClass' : 'selectable-selected' });
|
241
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
242
|
+
expect($radioLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
243
|
+
});
|
154
244
|
});
|
155
245
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
246
|
+
describe("If a checkbox in the set receives focus", function () {
|
247
|
+
it("Should add the focused class to that checkbox", function () {
|
248
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
249
|
+
$checkboxButtons.eq(0).focus();
|
250
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
251
|
+
});
|
252
|
+
|
253
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
254
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'focusedClass' : 'selectable-focused' });
|
255
|
+
$checkboxButtons.eq(0).focus();
|
256
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
257
|
+
});
|
258
|
+
});
|
164
259
|
|
165
|
-
|
166
|
-
|
167
|
-
|
260
|
+
describe("If a checkbox in the set loses focus", function () {
|
261
|
+
it("Should add the focused class to that checkbox", function () {
|
262
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
263
|
+
$checkboxButtons.eq(0).focus();
|
264
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
265
|
+
$checkboxButtons.eq(0).blur();
|
266
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(false);
|
267
|
+
});
|
168
268
|
|
269
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
270
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'focusedClass' : 'selectable-focused' });
|
271
|
+
$checkboxButtons.eq(0).focus();
|
272
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
273
|
+
$checkboxButtons.eq(0).blur();
|
274
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
275
|
+
});
|
169
276
|
});
|
170
|
-
});
|
171
277
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
278
|
+
describe("If one of those checkboxes is clicked", function () {
|
279
|
+
it("Should add the selected class to that checkbox", function () {
|
280
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
281
|
+
$checkboxButtons.eq(0)
|
282
|
+
.attr('checked', true)
|
283
|
+
.trigger('click');
|
284
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
285
|
+
});
|
177
286
|
|
178
|
-
|
179
|
-
|
287
|
+
it("Should add the selected class to that checkbox", function () {
|
288
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'selectedClass' : 'selectable-selected' });
|
289
|
+
$checkboxButtons.eq(0)
|
290
|
+
.attr('checked', true)
|
291
|
+
.trigger('click');
|
292
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
293
|
+
});
|
294
|
+
});
|
295
|
+
|
296
|
+
describe("If a radio in the set receives focus", function () {
|
297
|
+
it("Should add the focused class to that radio", function () {
|
298
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
299
|
+
$radioButtons.eq(0).focus();
|
300
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
301
|
+
});
|
180
302
|
|
181
|
-
|
303
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
304
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'focusedClass' : 'selectable-focused' });
|
305
|
+
$radioButtons.eq(0).focus();
|
306
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
307
|
+
});
|
308
|
+
});
|
309
|
+
|
310
|
+
describe("If a radio in the set loses focus", function () {
|
311
|
+
it("Should remove the focused class from that radio", function () {
|
312
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
313
|
+
$radioButtons.eq(0).focus();
|
314
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
315
|
+
$radioButtons.eq(0).blur();
|
316
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(false);
|
317
|
+
});
|
318
|
+
|
319
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
320
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons, { 'focusedClass' : 'selectable-focused' });
|
321
|
+
$radioButtons.eq(0).focus();
|
322
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
323
|
+
$radioButtons.eq(0).blur();
|
324
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
325
|
+
});
|
182
326
|
});
|
183
327
|
|
184
|
-
|
185
|
-
|
186
|
-
|
328
|
+
describe("If a radio in the set is clicked", function () {
|
329
|
+
it("Should mark that radio with the selected class", function () {
|
330
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
331
|
+
$radioButtons.eq(0)
|
332
|
+
.attr('checked', true)
|
333
|
+
.trigger('click');
|
334
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
335
|
+
});
|
187
336
|
|
188
|
-
|
337
|
+
it("Should remove the selected class from all other radios", function () {
|
338
|
+
buttonsInstance = new GOVUK.SelectionButtons($mixedButtons);
|
339
|
+
$radioLabels.eq(1).addClass('selected');
|
340
|
+
$radioButtons.eq(0)
|
341
|
+
.attr('checked', true)
|
342
|
+
.trigger('click');
|
343
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
344
|
+
});
|
189
345
|
});
|
190
346
|
});
|
191
347
|
});
|
192
348
|
|
193
|
-
describe("
|
194
|
-
|
195
|
-
|
349
|
+
describe("When new GOVUK.SelectionButtons is called with a selector", function () {
|
350
|
+
describe("When that selector matches radio inputs", function () {
|
351
|
+
afterEach(function () {
|
352
|
+
buttonsInstance.destroy();
|
353
|
+
});
|
196
354
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
355
|
+
describe("At the point it is called", function () {
|
356
|
+
it("Should do nothing if no radios are checked", function () {
|
357
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
358
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(false);
|
359
|
+
expect($radioLabels.eq(1).hasClass('selected')).toBe(false);
|
360
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
361
|
+
});
|
202
362
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
};
|
363
|
+
it("Should mark checked radios with the selected class", function () {
|
364
|
+
$radioButtons.eq(0).attr('checked', true);
|
365
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
366
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
367
|
+
});
|
209
368
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
369
|
+
it("Should mark checked radios with the custom selected class if given", function () {
|
370
|
+
$radioButtons.eq(0).attr('checked', true);
|
371
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']", { 'selectedClass' : 'selectable-selected' });
|
372
|
+
expect($radioLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
373
|
+
});
|
374
|
+
});
|
375
|
+
|
376
|
+
describe("If one of those radios receives focus", function () {
|
377
|
+
it("Should add the focused class to that radio", function () {
|
378
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
379
|
+
$radioButtons.eq(0).focus();
|
380
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
381
|
+
});
|
382
|
+
|
383
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
384
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']", { 'focusedClass' : 'selectable-focused' });
|
385
|
+
$radioButtons.eq(0).focus();
|
386
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
387
|
+
});
|
214
388
|
});
|
215
|
-
});
|
216
389
|
|
217
|
-
|
218
|
-
|
219
|
-
|
390
|
+
describe("If one of those radios loses focus", function () {
|
391
|
+
it("Should remove the focused class from that radio", function () {
|
392
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
393
|
+
$radioButtons.eq(0).focus();
|
394
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true);
|
395
|
+
$radioButtons.eq(0).blur();
|
396
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(false);
|
397
|
+
});
|
398
|
+
|
399
|
+
it("Should add a custom focused class to that radio if specified as an option", function () {
|
400
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']", { 'focusedClass' : 'selectable-focused' });
|
401
|
+
$radioButtons.eq(0).focus();
|
402
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
403
|
+
$radioButtons.eq(0).blur();
|
404
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
405
|
+
});
|
406
|
+
});
|
407
|
+
|
408
|
+
describe("If one of those radios is clicked", function () {
|
409
|
+
it("Should mark that radio with the selected class", function () {
|
410
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
411
|
+
$radioButtons.eq(0)
|
412
|
+
.attr('checked', true)
|
413
|
+
.trigger('click');
|
414
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
415
|
+
});
|
220
416
|
|
221
|
-
|
222
|
-
|
223
|
-
|
417
|
+
it("Should remove the selected class from all other radios", function () {
|
418
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
419
|
+
$radioLabels.eq(1).addClass('selected');
|
420
|
+
$radioButtons.eq(0)
|
421
|
+
.attr('checked', true)
|
422
|
+
.trigger('click');
|
423
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
424
|
+
});
|
224
425
|
});
|
225
426
|
});
|
226
427
|
|
227
|
-
describe("
|
228
|
-
|
428
|
+
describe("When that selector matches checkbox inputs", function () {
|
429
|
+
afterEach(function () {
|
430
|
+
buttonsInstance.destroy();
|
431
|
+
});
|
229
432
|
|
230
|
-
|
231
|
-
|
232
|
-
'
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
});
|
251
|
-
$checkboxButtons.eq(0).attr('checked', true);
|
252
|
-
GOVUK.CheckboxButtons.prototype.bindEvents.call(checkboxButtonsMock);
|
253
|
-
expect(eventCalled).toBe(true);
|
254
|
-
callback({ 'target' : $checkboxButtons.eq(0) });
|
255
|
-
expect(checkboxButtonsMock.markSelected).toHaveBeenCalled();
|
256
|
-
});
|
257
|
-
|
258
|
-
it("Should add focus and blur events to each checkbox that fires the markFocused method", function () {
|
259
|
-
var eventCalled = false;
|
260
|
-
|
261
|
-
checkboxButtonsMock.markFocused = function () {};
|
262
|
-
checkboxButtonsMock.markSelected = function () {};
|
263
|
-
checkboxButtonsMock.selectionEvents = 'click';
|
264
|
-
checkboxButtonsMock.focusEvents = 'focus blur';
|
265
|
-
spyOn(checkboxButtonsMock, 'markFocused');
|
266
|
-
spyOn($.fn, 'on').andCallFake(function (evt, func) {
|
267
|
-
if (evt === 'focus blur') {
|
268
|
-
eventCalled = true;
|
269
|
-
callback = func;
|
270
|
-
}
|
271
|
-
return $.fn;
|
433
|
+
describe("At the point it is called", function () {
|
434
|
+
it("Should do nothing if no checkboxes are checked", function () {
|
435
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
436
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(false);
|
437
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(false);
|
438
|
+
expect($checkboxLabels.eq(2).hasClass('selected')).toBe(false);
|
439
|
+
});
|
440
|
+
|
441
|
+
it("Should mark checked checkboxes with the selected class", function () {
|
442
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
443
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
444
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
445
|
+
});
|
446
|
+
|
447
|
+
it("Should mark all checked checkboxes with the selected class if there are more than one", function () {
|
448
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
449
|
+
$checkboxButtons.eq(1).attr('checked', true);
|
450
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
451
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
452
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(true);
|
272
453
|
});
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
'
|
277
|
-
'
|
454
|
+
|
455
|
+
it("Should mark checked checkboxes with the custom selected class if given", function () {
|
456
|
+
$checkboxButtons.eq(0).attr('checked', true);
|
457
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']", { 'selectedClass' : 'selectable-selected' });
|
458
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
459
|
+
});
|
460
|
+
});
|
461
|
+
|
462
|
+
describe("If one of those checkboxes receives focus", function () {
|
463
|
+
it("Should add the focused class to that checkbox", function () {
|
464
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
465
|
+
$checkboxButtons.eq(0).focus();
|
466
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
467
|
+
});
|
468
|
+
|
469
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
470
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']", { 'focusedClass' : 'selectable-focused' });
|
471
|
+
$checkboxButtons.eq(0).focus();
|
472
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
473
|
+
});
|
474
|
+
});
|
475
|
+
|
476
|
+
describe("If one of those checkboxes loses focus", function () {
|
477
|
+
it("Should add the focused class to that checkbox", function () {
|
478
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
479
|
+
$checkboxButtons.eq(0).focus();
|
480
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
481
|
+
$checkboxButtons.eq(0).blur();
|
482
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(false);
|
483
|
+
});
|
484
|
+
|
485
|
+
it("Should add a custom focused class to that checkbox if specified as an option", function () {
|
486
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']", { 'focusedClass' : 'selectable-focused' });
|
487
|
+
$checkboxButtons.eq(0).focus();
|
488
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
489
|
+
$checkboxButtons.eq(0).blur();
|
490
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(false);
|
278
491
|
});
|
279
|
-
expect(checkboxButtonsMock.markFocused).toHaveBeenCalled();
|
280
492
|
});
|
281
493
|
});
|
282
494
|
|
283
|
-
describe("
|
284
|
-
var
|
285
|
-
'selectedClass' : 'selected'
|
286
|
-
};
|
495
|
+
describe("When that selector matches a mixture of checkbox and radio inputs", function () {
|
496
|
+
var $mixedButtons;
|
287
497
|
|
288
|
-
|
289
|
-
$checkboxButtons.
|
290
|
-
GOVUK.CheckboxButtons.prototype.markSelected.call(checkboxButtonsMock, $checkboxButtons.eq(0));
|
291
|
-
expect($checkboxLabels.eq(0).hasClass(checkboxButtonsMock.selectedClass)).toBe(true);
|
498
|
+
beforeEach(function () {
|
499
|
+
$mixedButtons = $checkboxButtons.add($radioButtons);
|
292
500
|
});
|
293
501
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
502
|
+
afterEach(function () {
|
503
|
+
buttonsInstance.destroy();
|
504
|
+
});
|
505
|
+
|
506
|
+
it("Should do nothing if no checkboxes or radios are checked", function () {
|
507
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input");
|
508
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(false);
|
509
|
+
expect($checkboxLabels.eq(1).hasClass('selected')).toBe(false);
|
510
|
+
expect($checkboxLabels.eq(2).hasClass('selected')).toBe(false);
|
511
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(false);
|
512
|
+
expect($radioLabels.eq(1).hasClass('selected')).toBe(false);
|
513
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
514
|
+
});
|
515
|
+
|
516
|
+
it("Should mark checked checkboxes or radios with the selected class", function () {
|
517
|
+
$mixedButtons.eq(0).attr('checked', true);
|
518
|
+
$mixedButtons.eq(3).attr('checked', true);
|
519
|
+
|
520
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input");
|
521
|
+
expect($checkboxLabels.eq(0).hasClass('selected')).toBe(true);
|
522
|
+
expect($radioLabels.eq(0).hasClass('selected')).toBe(true);
|
523
|
+
});
|
524
|
+
|
525
|
+
it("Should mark checked checkboxes or radios with the custom selected class if given", function () {
|
526
|
+
$mixedButtons.eq(0).attr('checked', true);
|
527
|
+
$mixedButtons.eq(3).attr('checked', true);
|
528
|
+
|
529
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input", { 'selectedClass' : 'selectable-selected' });
|
530
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
531
|
+
expect($radioLabels.eq(0).hasClass('selectable-selected')).toBe(true);
|
298
532
|
});
|
299
533
|
});
|
534
|
+
});
|
535
|
+
|
536
|
+
describe("When GOVUK.SelectionButtons is called with a selector and then the page content is replaced", function () {
|
537
|
+
describe("When that selector matches radio inputs", function () {
|
538
|
+
describe("If one of those radios is clicked", function () {
|
539
|
+
afterEach(function () {
|
540
|
+
buttonsInstance.destroy();
|
541
|
+
});
|
542
|
+
|
543
|
+
it("Should mark that radio with the selected class", function () {
|
544
|
+
var contentCache;
|
545
|
+
|
546
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
547
|
+
contentCache = $('#content').html();
|
548
|
+
$('#content').html('');
|
549
|
+
$('#content').html(contentCache);
|
550
|
+
$("label.selectable input[type='radio']").eq(0)
|
551
|
+
.attr('checked', true)
|
552
|
+
.trigger('click');
|
553
|
+
expect($("label.selectable input[type='radio']").eq(0).parent('label').hasClass('selected')).toBe(true);
|
554
|
+
});
|
555
|
+
|
556
|
+
it("Should remove the selected class from all other radios", function () {
|
557
|
+
var contentCache;
|
558
|
+
|
559
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
560
|
+
contentCache = $('#content').html();
|
561
|
+
$('#content').html('');
|
562
|
+
$('#content').html(contentCache);
|
563
|
+
$radioButtons = $("label.selectable input[type='radio']");
|
564
|
+
$radioLabels = $radioButtons.parent('label');
|
565
|
+
$radioLabels.eq(1).addClass('selected');
|
566
|
+
$radioButtons.eq(0)
|
567
|
+
.attr('checked', true)
|
568
|
+
.trigger('click');
|
569
|
+
expect($radioLabels.eq(2).hasClass('selected')).toBe(false);
|
570
|
+
});
|
571
|
+
});
|
572
|
+
|
573
|
+
describe("If one of those radios is focused", function () {
|
574
|
+
afterEach(function () {
|
575
|
+
buttonsInstance.destroy();
|
576
|
+
});
|
300
577
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
578
|
+
it("Should add the focused class to the radio", function () {
|
579
|
+
var contentCache;
|
580
|
+
|
581
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
582
|
+
contentCache = $('#content').html();
|
583
|
+
$('#content').html('');
|
584
|
+
$('#content').html(contentCache);
|
585
|
+
$radioButtons = $("label.selectable input[type='radio']");
|
586
|
+
$radioLabels = $radioButtons.parent('label');
|
587
|
+
$radioButtons.eq(0).focus();
|
588
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true)
|
589
|
+
});
|
306
590
|
|
307
|
-
|
308
|
-
|
591
|
+
it("Should add a custom focused class to the radio if sent in as an option", function () {
|
592
|
+
var contentCache;
|
593
|
+
|
594
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']", { 'focusedClass' : 'selectable-focused' });
|
595
|
+
contentCache = $('#content').html();
|
596
|
+
$('#content').html('');
|
597
|
+
$('#content').html(contentCache);
|
598
|
+
$radioButtons = $("label.selectable input[type='radio']");
|
599
|
+
$radioLabels = $radioButtons.parent('label');
|
600
|
+
$radioButtons.eq(0).focus();
|
601
|
+
expect($radioLabels.eq(0).hasClass('selectable-focused')).toBe(true)
|
602
|
+
});
|
309
603
|
|
310
|
-
|
604
|
+
it("Should remove the focused class from a radio when it loses focus", function () {
|
605
|
+
var contentCache;
|
606
|
+
|
607
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='radio']");
|
608
|
+
contentCache = $('#content').html();
|
609
|
+
$('#content').html('');
|
610
|
+
$('#content').html(contentCache);
|
611
|
+
$radioButtons = $("label.selectable input[type='radio']");
|
612
|
+
$radioLabels = $radioButtons.parent('label');
|
613
|
+
$radioButtons.eq(0).focus();
|
614
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(true)
|
615
|
+
$radioButtons.eq(0).blur();
|
616
|
+
expect($radioLabels.eq(0).hasClass('focused')).toBe(false)
|
617
|
+
});
|
311
618
|
});
|
619
|
+
});
|
312
620
|
|
313
|
-
|
314
|
-
|
315
|
-
|
621
|
+
describe("When that selector matches checkbox inputs", function () {
|
622
|
+
describe("If one of those checkboxes is clicked", function () {
|
623
|
+
afterEach(function () {
|
624
|
+
buttonsInstance.destroy();
|
625
|
+
});
|
316
626
|
|
317
|
-
|
627
|
+
it("Should add the selected class to the checkbox", function () {
|
628
|
+
var contentCache;
|
629
|
+
|
630
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
631
|
+
contentCache = $('#content').html();
|
632
|
+
$('#content').html('');
|
633
|
+
$('#content').html(contentCache);
|
634
|
+
$("label.selectable input[type='checkbox']").eq(0)
|
635
|
+
.attr('checked', true)
|
636
|
+
.trigger('click');
|
637
|
+
expect($("label.selectable input[type='checkbox']").eq(0).parent('label').hasClass('selected')).toBe(true);
|
638
|
+
});
|
639
|
+
});
|
640
|
+
|
641
|
+
describe("If one of those checkboxes is focused", function () {
|
642
|
+
afterEach(function () {
|
643
|
+
buttonsInstance.destroy();
|
644
|
+
});
|
645
|
+
|
646
|
+
it("Should add the focused class to the checkbox", function () {
|
647
|
+
var contentCache;
|
648
|
+
|
649
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
650
|
+
contentCache = $('#content').html();
|
651
|
+
$('#content').html('');
|
652
|
+
$('#content').html(contentCache);
|
653
|
+
$checkboxButtons = $("label.selectable input[type='checkbox']");
|
654
|
+
$checkboxLabels = $checkboxButtons.parent('label');
|
655
|
+
$checkboxButtons.eq(0).focus();
|
656
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
657
|
+
});
|
658
|
+
|
659
|
+
it("Should add a custom focused class to the checkbox if sent in as an option", function () {
|
660
|
+
var contentCache;
|
661
|
+
|
662
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']", { 'focusedClass' : 'selectable-focused' });
|
663
|
+
contentCache = $('#content').html();
|
664
|
+
$('#content').html('');
|
665
|
+
$('#content').html(contentCache);
|
666
|
+
$checkboxButtons = $("label.selectable input[type='checkbox']");
|
667
|
+
$checkboxLabels = $checkboxButtons.parent('label');
|
668
|
+
$checkboxButtons.eq(0).focus();
|
669
|
+
expect($checkboxLabels.eq(0).hasClass('selectable-focused')).toBe(true);
|
670
|
+
});
|
671
|
+
|
672
|
+
it("Should remove the focused class from the checkbox when it loses focus", function () {
|
673
|
+
var contentCache;
|
674
|
+
|
675
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
676
|
+
contentCache = $('#content').html();
|
677
|
+
$('#content').html('');
|
678
|
+
$('#content').html(contentCache);
|
679
|
+
$checkboxButtons = $("label.selectable input[type='checkbox']");
|
680
|
+
$checkboxLabels = $checkboxButtons.parent('label');
|
681
|
+
$checkboxButtons.eq(0).focus();
|
682
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(true);
|
683
|
+
$checkboxButtons.eq(0).blur();
|
684
|
+
expect($checkboxLabels.eq(0).hasClass('focused')).toBe(false);
|
685
|
+
});
|
318
686
|
});
|
319
687
|
});
|
320
688
|
});
|
321
689
|
|
322
|
-
describe("
|
323
|
-
it("Should
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
690
|
+
describe("GOVUK.SelectionButtons.prototype.destroy", function () {
|
691
|
+
it("Should remove the events bound to the jQuery-wrapped elements sent into GOVUK.SelectionButtons", function () {
|
692
|
+
var clickCallbackBound = false,
|
693
|
+
focusBlurCallbackBound = false,
|
694
|
+
clickCallbackCancelled = false,
|
695
|
+
focusBlurCallbackCancelled = false;
|
696
|
+
|
697
|
+
spyOn($.fn, "on").andCallFake(function (evt, callback) {
|
698
|
+
if (this === $radioButtons) {
|
699
|
+
if (evt === "click") {
|
700
|
+
clickCallbackBound = callback;
|
701
|
+
}
|
702
|
+
if (evt === "focus blur") {
|
703
|
+
focusBlurCallbackBound = callback;
|
704
|
+
}
|
705
|
+
}
|
706
|
+
return this;
|
707
|
+
});
|
708
|
+
|
709
|
+
spyOn($.fn, "off").andCallFake(function (evt, callback) {
|
710
|
+
if (this === $radioButtons) {
|
711
|
+
if (evt === "click") {
|
712
|
+
clickCallbackCancelled = callback;
|
713
|
+
}
|
714
|
+
if (evt === "focus blur") {
|
715
|
+
focusBlurCallbackCancelled = callback;
|
716
|
+
}
|
717
|
+
}
|
718
|
+
return this;
|
719
|
+
});
|
720
|
+
buttonsInstance = new GOVUK.SelectionButtons($radioButtons);
|
721
|
+
expect(clickCallbackBound).not.toBe(false);
|
722
|
+
expect(focusBlurCallbackBound).not.toBe(false);
|
723
|
+
buttonsInstance.destroy();
|
724
|
+
expect(clickCallbackCancelled).toEqual(clickCallbackBound);
|
725
|
+
expect(focusBlurCallbackCancelled).toEqual(focusBlurCallbackBound);
|
726
|
+
});
|
727
|
+
|
728
|
+
it("Should remove the events bound to the document for the selector was sent into GOVUK.SelectionButtons", function () {
|
729
|
+
var clickCallbackBound = false,
|
730
|
+
focusBlurCallbackBound = false,
|
731
|
+
clickCallbackCancelled = false,
|
732
|
+
focusBlurCallbackCancelled = false;
|
733
|
+
|
734
|
+
spyOn($.fn, "on").andCallFake(function (evt, selector, callback) {
|
735
|
+
if ((this[0] === document) && (selector === "label.selectable input[type='checkbox']")) {
|
736
|
+
if (evt === "click") {
|
737
|
+
clickCallbackBound = callback;
|
738
|
+
}
|
739
|
+
if (evt === "focus blur") {
|
740
|
+
focusBlurCallbackBound = callback;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
return this;
|
744
|
+
});
|
745
|
+
|
746
|
+
spyOn($.fn, "off").andCallFake(function (evt, selector, callback) {
|
747
|
+
if ((this[0] === document) && (selector === "label.selectable input[type='checkbox']")) {
|
748
|
+
if (evt === "click") {
|
749
|
+
clickCallbackCancelled = callback;
|
750
|
+
}
|
751
|
+
if (evt === "focus blur") {
|
752
|
+
focusBlurCallbackCancelled = callback;
|
753
|
+
}
|
754
|
+
}
|
755
|
+
return this;
|
756
|
+
});
|
757
|
+
buttonsInstance = new GOVUK.SelectionButtons("label.selectable input[type='checkbox']");
|
758
|
+
expect(clickCallbackBound).not.toBe(false);
|
759
|
+
expect(focusBlurCallbackBound).not.toBe(false);
|
760
|
+
buttonsInstance.destroy();
|
761
|
+
expect(clickCallbackCancelled).toEqual(clickCallbackBound);
|
762
|
+
expect(focusBlurCallbackCancelled).toEqual(focusBlurCallbackBound);
|
763
|
+
});
|
342
764
|
});
|
343
765
|
});
|