@ons/design-system 50.0.1 → 51.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.
- package/README.md +35 -13
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +162 -0
- package/components/access-code/uac.spec.js +26 -0
- package/components/accordion/_macro.spec.js +224 -0
- package/components/accordion/accordion.spec.js +134 -0
- package/components/address-input/_macro.njk +1 -1
- package/components/address-input/_macro.spec.js +465 -0
- package/components/address-input/autosuggest.address.js +5 -4
- package/components/address-input/autosuggest.address.setter.js +3 -1
- package/components/address-input/autosuggest.address.spec.js +733 -0
- package/components/address-output/_macro.njk +6 -6
- package/components/address-output/_macro.spec.js +122 -0
- package/components/autosuggest/_macro.njk +1 -1
- package/components/autosuggest/_macro.spec.js +229 -0
- package/components/autosuggest/autosuggest.helpers.js +2 -3
- package/components/autosuggest/autosuggest.helpers.spec.js +85 -0
- package/components/autosuggest/autosuggest.js +4 -2
- package/components/autosuggest/autosuggest.spec.js +625 -0
- package/components/autosuggest/autosuggest.ui.js +6 -2
- package/components/breadcrumbs/_macro.spec.js +129 -0
- package/components/button/_macro.njk +5 -5
- package/components/button/_macro.spec.js +446 -0
- package/components/button/button.spec.js +290 -0
- package/components/call-to-action/_macro.njk +3 -1
- package/components/call-to-action/_macro.spec.js +52 -0
- package/components/card/_macro.njk +26 -19
- package/components/card/_macro.spec.js +261 -0
- package/components/char-check-limit/_macro.spec.js +73 -0
- package/components/char-check-limit/character-check.spec.js +196 -0
- package/components/char-check-limit/character-limit.js +1 -1
- package/components/checkboxes/_checkbox-macro.spec.js +419 -0
- package/components/checkboxes/_macro.njk +1 -3
- package/components/checkboxes/_macro.spec.js +306 -0
- package/components/checkboxes/checkboxes.spec.js +208 -0
- package/components/code-highlight/_macro.spec.js +56 -0
- package/components/code-highlight/code-highlight.spec.js +18 -0
- package/components/collapsible/_macro.spec.js +204 -0
- package/components/collapsible/collapsible.js +2 -1
- package/components/collapsible/collapsible.spec.js +236 -0
- package/components/content-pagination/_macro.spec.js +199 -0
- package/components/cookies-banner/_macro.njk +1 -1
- package/components/cookies-banner/_macro.spec.js +171 -0
- package/components/cookies-banner/cookies-banner.spec.js +90 -0
- package/components/date-input/_macro.njk +6 -3
- package/components/date-input/_macro.spec.js +286 -0
- package/components/document-list/_macro.njk +3 -5
- package/components/document-list/_macro.spec.js +491 -0
- package/components/download-resources/download-resources.spec.js +540 -0
- package/components/duration/_macro.njk +7 -6
- package/components/duration/_macro.spec.js +251 -0
- package/components/error/_macro.spec.js +97 -0
- package/components/external-link/_macro.spec.js +60 -0
- package/components/feedback/_macro.njk +5 -3
- package/components/feedback/_macro.spec.js +122 -0
- package/components/field/_macro.njk +2 -2
- package/components/field/_macro.spec.js +97 -0
- package/components/fieldset/_macro.njk +3 -3
- package/components/fieldset/_macro.spec.js +173 -0
- package/components/footer/_macro.njk +11 -48
- package/components/footer/_macro.spec.js +549 -0
- package/components/header/_macro.njk +2 -2
- package/components/header/_macro.spec.js +562 -0
- package/components/hero/_hero.scss +0 -3
- package/components/hero/_macro.njk +4 -4
- package/components/hero/_macro.spec.js +224 -0
- package/components/icons/_macro.njk +15 -15
- package/components/icons/_macro.spec.js +140 -0
- package/components/images/_macro.njk +1 -1
- package/components/images/_macro.spec.js +121 -0
- package/components/input/_input-type.scss +12 -5
- package/components/input/_macro.njk +4 -5
- package/components/input/_macro.spec.js +658 -0
- package/components/label/_macro.spec.js +189 -0
- package/components/language-selector/_macro.spec.js +129 -0
- package/components/lists/_list.scss +4 -0
- package/components/lists/_macro.njk +4 -7
- package/components/lists/_macro.spec.js +618 -0
- package/components/message/_macro.spec.js +137 -0
- package/components/message-list/_macro.njk +7 -7
- package/components/message-list/_macro.spec.js +159 -0
- package/components/metadata/_macro.spec.js +167 -0
- package/components/modal/_macro.njk +6 -6
- package/components/modal/_macro.spec.js +87 -0
- package/components/modal/modal.spec.js +59 -0
- package/components/mutually-exclusive/_macro.njk +1 -1
- package/components/mutually-exclusive/_macro.spec.js +182 -0
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
- package/components/navigation/_macro.njk +6 -6
- package/components/navigation/_macro.spec.js +327 -0
- package/components/navigation/navigation.dom.js +1 -1
- package/components/navigation/navigation.spec.js +232 -0
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_macro.spec.js +411 -0
- package/components/panel/_macro.njk +6 -6
- package/components/panel/_macro.spec.js +423 -0
- package/components/password/_macro.spec.js +137 -0
- package/components/password/password.spec.js +40 -0
- package/components/phase-banner/_macro.spec.js +73 -0
- package/components/promotional-banner/_macro.spec.js +97 -0
- package/components/question/_macro.njk +25 -33
- package/components/question/_macro.spec.js +309 -0
- package/components/quote/_macro.spec.js +81 -0
- package/components/radios/_macro.njk +3 -6
- package/components/radios/_macro.spec.js +575 -0
- package/components/radios/radios.spec.js +180 -0
- package/components/related-content/_macro.njk +1 -0
- package/components/related-content/_macro.spec.js +142 -0
- package/components/relationships/_macro.spec.js +108 -0
- package/components/relationships/relationships.spec.js +84 -0
- package/components/reply/_macro.njk +2 -2
- package/components/reply/_macro.spec.js +69 -0
- package/components/reply/reply.spec.js +78 -0
- package/components/search/_macro.njk +14 -12
- package/components/search/_macro.spec.js +44 -0
- package/components/search/_search.scss +7 -7
- package/components/section-navigation/_macro.njk +7 -2
- package/components/section-navigation/_macro.spec.js +206 -0
- package/components/select/_macro.njk +3 -3
- package/components/select/_macro.spec.js +203 -0
- package/components/select/select.spec.js +56 -0
- package/components/share-page/_macro.njk +2 -2
- package/components/share-page/_macro.spec.js +110 -0
- package/components/skip-to-content/_macro.spec.js +57 -0
- package/components/skip-to-content/skip-to-content.spec.js +44 -0
- package/components/status/_macro.spec.js +77 -0
- package/components/summary/_macro.njk +5 -5
- package/components/summary/_macro.spec.js +472 -0
- package/components/table/_macro.njk +2 -2
- package/components/table/_macro.spec.js +557 -0
- package/components/table/table.spec.js +155 -0
- package/components/table-of-contents/_macro.njk +35 -35
- package/components/table-of-contents/_macro.spec.js +178 -0
- package/components/table-of-contents/toc.js +29 -25
- package/components/table-of-contents/toc.spec.js +61 -0
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +79 -0
- package/components/tabs/tabs.spec.js +162 -0
- package/components/text-indent/_macro.spec.js +52 -0
- package/components/textarea/_macro.njk +5 -3
- package/components/textarea/_macro.spec.js +300 -0
- package/components/textarea/textarea.spec.js +98 -0
- package/components/timeline/_macro.njk +3 -3
- package/components/timeline/_macro.spec.js +81 -0
- package/components/timeout-modal/_macro.spec.js +68 -0
- package/components/timeout-modal/timeout-modal.spec.js +226 -0
- package/components/timeout-panel/_macro.njk +0 -1
- package/components/timeout-panel/_macro.spec.js +54 -0
- package/components/timeout-panel/timeout-panel.dom.js +1 -2
- package/components/timeout-panel/timeout-panel.spec.js +161 -0
- package/components/upload/_macro.spec.js +75 -0
- package/components/video/_macro.spec.js +34 -0
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/cookies-settings.spec.js +154 -0
- package/package.json +10 -23
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
|
|
5
|
+
import axe from '../../tests/helpers/axe';
|
|
6
|
+
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
|
+
|
|
8
|
+
const EXAMPLE_CHECKBOX = {
|
|
9
|
+
id: 'example-checkbox-id',
|
|
10
|
+
name: 'example-checkbox-name',
|
|
11
|
+
value: '123',
|
|
12
|
+
label: {
|
|
13
|
+
classes: 'extra-label-class',
|
|
14
|
+
text: 'Example checkbox',
|
|
15
|
+
description: 'Example label description.',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const EXAMPLE_CHECKBOXES_ITEM_INPUT = {
|
|
20
|
+
value: 'input',
|
|
21
|
+
other: {
|
|
22
|
+
id: 'example-text-input',
|
|
23
|
+
name: 'example-text-input-name',
|
|
24
|
+
type: 'text',
|
|
25
|
+
label: {
|
|
26
|
+
text: 'Enter your own answer',
|
|
27
|
+
},
|
|
28
|
+
required: false,
|
|
29
|
+
classes: 'extra-textbox-class',
|
|
30
|
+
width: 42,
|
|
31
|
+
value: '42',
|
|
32
|
+
attributes: { a: 42 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const EXAMPLE_CHECKBOXES_ITEM_SELECT = {
|
|
37
|
+
value: 'select',
|
|
38
|
+
other: {
|
|
39
|
+
otherType: 'select',
|
|
40
|
+
id: 'example-select',
|
|
41
|
+
name: 'example-select-name',
|
|
42
|
+
label: {
|
|
43
|
+
text: 'Enter your own answer',
|
|
44
|
+
},
|
|
45
|
+
classes: 'extra-select-class',
|
|
46
|
+
options: [
|
|
47
|
+
{ text: 'First', value: '1' },
|
|
48
|
+
{ text: 'Second', value: '2' },
|
|
49
|
+
],
|
|
50
|
+
value: '1',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES = {
|
|
55
|
+
value: 'checkboxes',
|
|
56
|
+
other: {
|
|
57
|
+
otherType: 'checkboxes',
|
|
58
|
+
selectAllChildren: true,
|
|
59
|
+
id: 'example-checkboxes',
|
|
60
|
+
name: 'example-checkboxes-name',
|
|
61
|
+
legend: 'Select preferred times of day',
|
|
62
|
+
legendClasses: 'extra-legend-class',
|
|
63
|
+
attributes: { a: 42 },
|
|
64
|
+
checkboxes: [
|
|
65
|
+
{
|
|
66
|
+
value: 'morning',
|
|
67
|
+
id: 'morning',
|
|
68
|
+
label: {
|
|
69
|
+
text: 'Morning',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: 'afternoon',
|
|
74
|
+
id: 'afternoon',
|
|
75
|
+
label: {
|
|
76
|
+
text: 'Afternoon',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
autoSelect: {
|
|
81
|
+
selectAllText: 'Select all',
|
|
82
|
+
unselectAllText: 'Unselect all',
|
|
83
|
+
context: 'checkboxes',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const EXAMPLE_CHECKBOXES_ITEM_RADIOS = {
|
|
89
|
+
value: 'radios',
|
|
90
|
+
other: {
|
|
91
|
+
otherType: 'radios',
|
|
92
|
+
id: 'example-radios',
|
|
93
|
+
name: 'example-radios-name',
|
|
94
|
+
legend: 'Select preferred times of day',
|
|
95
|
+
legendClasses: 'extra-legend-class',
|
|
96
|
+
attributes: { a: 42 },
|
|
97
|
+
radios: [EXAMPLE_CHECKBOX],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
describe('macro: checkboxes/checkbox', () => {
|
|
102
|
+
it('passes jest-axe checks without check', async () => {
|
|
103
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
104
|
+
|
|
105
|
+
const results = await axe($.html());
|
|
106
|
+
expect(results).toHaveNoViolations();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('has additionally provided `classes`', () => {
|
|
110
|
+
const $ = cheerio.load(
|
|
111
|
+
renderComponent('checkboxes/checkbox', {
|
|
112
|
+
...EXAMPLE_CHECKBOX,
|
|
113
|
+
classes: 'extra-class another-extra-class',
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect($('.ons-checkbox').hasClass('extra-class')).toBe(true);
|
|
118
|
+
expect($('.ons-checkbox').hasClass('another-extra-class')).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('does not have `no-label` modifier class', () => {
|
|
122
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
123
|
+
|
|
124
|
+
expect($('.ons-checkbox').hasClass('ons-checkbox--no-label')).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('has `no-label` modifier class when `hideLabel` is `true`', () => {
|
|
128
|
+
const $ = cheerio.load(
|
|
129
|
+
renderComponent('checkboxes/checkbox', {
|
|
130
|
+
...EXAMPLE_CHECKBOX,
|
|
131
|
+
hideLabel: true,
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
expect($('.ons-checkbox').hasClass('ons-checkbox--no-label')).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('input element', () => {
|
|
139
|
+
it('renders `input` element of type "checkbox"', () => {
|
|
140
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
141
|
+
|
|
142
|
+
expect($('.ons-checkbox__input').is('input')).toBe(true);
|
|
143
|
+
expect($('.ons-checkbox__input').attr('type')).toBe('checkbox');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('has the provided `id` attribute', () => {
|
|
147
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
148
|
+
|
|
149
|
+
expect($('.ons-checkbox__input').attr('id')).toBe('example-checkbox-id');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('has the provided `name` attribute', () => {
|
|
153
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
154
|
+
|
|
155
|
+
expect($('.ons-checkbox__input').attr('name')).toBe('example-checkbox-name');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('does not have the `disabled` attribute when not disabled', () => {
|
|
159
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
160
|
+
|
|
161
|
+
expect($('.ons-checkbox__input').attr('disabled')).toBeUndefined();
|
|
162
|
+
expect($('.ons-checkbox__input').attr('aria-disabled')).toBeUndefined();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('has the `disabled` attribute when disabled', () => {
|
|
166
|
+
const $ = cheerio.load(
|
|
167
|
+
renderComponent('checkboxes/checkbox', {
|
|
168
|
+
...EXAMPLE_CHECKBOX,
|
|
169
|
+
disabled: true,
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
expect($('.ons-checkbox__input').attr('disabled')).toBe('disabled');
|
|
174
|
+
expect($('.ons-checkbox__input').attr('aria-disabled')).toBe('true');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('does not have the `checked` attribute when not checked', () => {
|
|
178
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
179
|
+
|
|
180
|
+
expect($('.ons-checkbox__input').attr('checked')).toBeUndefined();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('has the `checked` attribute when checked', () => {
|
|
184
|
+
const $ = cheerio.load(
|
|
185
|
+
renderComponent('checkboxes/checkbox', {
|
|
186
|
+
...EXAMPLE_CHECKBOX,
|
|
187
|
+
checked: true,
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
expect($('.ons-checkbox__input').attr('checked')).toBe('checked');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('has additionally provided `inputClasses`', () => {
|
|
195
|
+
const $ = cheerio.load(
|
|
196
|
+
renderComponent('checkboxes/checkbox', {
|
|
197
|
+
...EXAMPLE_CHECKBOX,
|
|
198
|
+
inputClasses: 'extra-input-class another-extra-input-class',
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
expect($('.ons-checkbox__input').hasClass('extra-input-class')).toBe(true);
|
|
203
|
+
expect($('.ons-checkbox__input').hasClass('another-extra-input-class')).toBe(true);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('does not associate with "other" input when there is none', () => {
|
|
207
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
208
|
+
|
|
209
|
+
expect($('.ons-checkbox__input').attr('aria-controls')).toBeUndefined();
|
|
210
|
+
expect($('.ons-checkbox__input').attr('aria-haspopup')).toBeUndefined();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('does not associate with "other" input when marked `open`', () => {
|
|
214
|
+
const $ = cheerio.load(
|
|
215
|
+
renderComponent('checkboxes/checkbox', {
|
|
216
|
+
...EXAMPLE_CHECKBOX,
|
|
217
|
+
other: {
|
|
218
|
+
open: true,
|
|
219
|
+
id: 'other-input-id',
|
|
220
|
+
label: {
|
|
221
|
+
text: 'Other input',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
expect($('.ons-checkbox__input').attr('aria-controls')).toBeUndefined();
|
|
228
|
+
expect($('.ons-checkbox__input').attr('aria-haspopup')).toBeUndefined();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('associates with "other" input when not marked `open`', () => {
|
|
232
|
+
const $ = cheerio.load(
|
|
233
|
+
renderComponent('checkboxes/checkbox', {
|
|
234
|
+
...EXAMPLE_CHECKBOX,
|
|
235
|
+
other: {
|
|
236
|
+
id: 'other-input-id',
|
|
237
|
+
label: {
|
|
238
|
+
text: 'Other input',
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
expect($('.ons-checkbox__input').attr('aria-controls')).toBe('example-checkbox-id-other-wrap');
|
|
245
|
+
expect($('.ons-checkbox__input').attr('aria-haspopup')).toBe('true');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('has additionally provided attributes', () => {
|
|
249
|
+
const $ = cheerio.load(
|
|
250
|
+
renderComponent('checkboxes/checkbox', {
|
|
251
|
+
...EXAMPLE_CHECKBOX,
|
|
252
|
+
attributes: { a: '123', b: '456' },
|
|
253
|
+
}),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
expect($('.ons-checkbox__input').attr('a')).toBe('123');
|
|
257
|
+
expect($('.ons-checkbox__input').attr('b')).toBe('456');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('does not have `data-deselect-message` when `deselectMessage` is not provided', () => {
|
|
261
|
+
const $ = cheerio.load(renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX));
|
|
262
|
+
|
|
263
|
+
expect($('.ons-checkbox__input').attr('data-deselect-message')).toBeUndefined();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('has `data-deselect-message` when `deselectMessage` is provided', () => {
|
|
267
|
+
const $ = cheerio.load(
|
|
268
|
+
renderComponent('checkboxes/checkbox', {
|
|
269
|
+
...EXAMPLE_CHECKBOX,
|
|
270
|
+
deselectMessage: 'Selecting this will clear your feedback',
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
expect($('.ons-checkbox__input').attr('data-deselect-message')).toBe('Selecting this will clear your feedback');
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe('label element', () => {
|
|
279
|
+
it('renders label using `label` component', () => {
|
|
280
|
+
const faker = templateFaker();
|
|
281
|
+
const labelSpy = faker.spy('label');
|
|
282
|
+
|
|
283
|
+
faker.renderComponent('checkboxes/checkbox', EXAMPLE_CHECKBOX);
|
|
284
|
+
|
|
285
|
+
expect(labelSpy.occurrences).toContainEqual({
|
|
286
|
+
id: 'example-checkbox-id-label',
|
|
287
|
+
for: 'example-checkbox-id',
|
|
288
|
+
inputType: 'checkbox',
|
|
289
|
+
text: 'Example checkbox',
|
|
290
|
+
classes: 'ons-checkbox__label extra-label-class',
|
|
291
|
+
description: 'Example label description.',
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('wraps `other` component without a class indicating that it is open', () => {
|
|
297
|
+
const $ = cheerio.load(
|
|
298
|
+
renderComponent('checkboxes/checkbox', {
|
|
299
|
+
...EXAMPLE_CHECKBOX,
|
|
300
|
+
...EXAMPLE_CHECKBOXES_ITEM_INPUT,
|
|
301
|
+
}),
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
expect($('.ons-checkbox__other').hasClass('ons-checkbox__other--open')).toBe(false);
|
|
305
|
+
expect($('.ons-checkbox__other').attr('id')).toBe('example-checkbox-id-other-wrap');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('wraps `other` component with class indicating that it is open', () => {
|
|
309
|
+
const $ = cheerio.load(
|
|
310
|
+
renderComponent('checkboxes/checkbox', {
|
|
311
|
+
...EXAMPLE_CHECKBOX,
|
|
312
|
+
...EXAMPLE_CHECKBOXES_ITEM_INPUT,
|
|
313
|
+
other: {
|
|
314
|
+
...EXAMPLE_CHECKBOXES_ITEM_INPUT.other,
|
|
315
|
+
open: true,
|
|
316
|
+
},
|
|
317
|
+
}),
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
expect($('.ons-checkbox__other').hasClass('ons-checkbox__other--open')).toBe(true);
|
|
321
|
+
expect($('.ons-checkbox__other').attr('id')).toBe('example-checkbox-id-other-wrap');
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('renders other "input" component for item', () => {
|
|
325
|
+
const faker = templateFaker();
|
|
326
|
+
const inputSpy = faker.spy('input');
|
|
327
|
+
|
|
328
|
+
faker.renderComponent('checkboxes/checkbox', {
|
|
329
|
+
...EXAMPLE_CHECKBOX,
|
|
330
|
+
...EXAMPLE_CHECKBOXES_ITEM_INPUT,
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
expect(inputSpy.occurrences).toContainEqual({
|
|
334
|
+
id: 'example-text-input',
|
|
335
|
+
name: 'example-text-input-name',
|
|
336
|
+
type: 'text',
|
|
337
|
+
label: {
|
|
338
|
+
id: 'example-text-input-label',
|
|
339
|
+
text: 'Enter your own answer',
|
|
340
|
+
classes: 'ons-u-fw-n',
|
|
341
|
+
},
|
|
342
|
+
required: false,
|
|
343
|
+
classes: 'extra-textbox-class',
|
|
344
|
+
width: 42,
|
|
345
|
+
attributes: EXAMPLE_CHECKBOXES_ITEM_INPUT.other.attributes,
|
|
346
|
+
dontWrap: true,
|
|
347
|
+
value: '42',
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('renders other "select" component for item', () => {
|
|
352
|
+
const faker = templateFaker();
|
|
353
|
+
const selectSpy = faker.spy('select');
|
|
354
|
+
|
|
355
|
+
faker.renderComponent('checkboxes/checkbox', {
|
|
356
|
+
...EXAMPLE_CHECKBOX,
|
|
357
|
+
...EXAMPLE_CHECKBOXES_ITEM_SELECT,
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
expect(selectSpy.occurrences).toContainEqual({
|
|
361
|
+
id: 'example-select',
|
|
362
|
+
name: 'example-select-name',
|
|
363
|
+
label: {
|
|
364
|
+
id: 'example-select-label',
|
|
365
|
+
text: 'Enter your own answer',
|
|
366
|
+
classes: 'ons-u-fw-n',
|
|
367
|
+
},
|
|
368
|
+
classes: 'extra-select-class',
|
|
369
|
+
dontWrap: true,
|
|
370
|
+
options: EXAMPLE_CHECKBOXES_ITEM_SELECT.other.options,
|
|
371
|
+
value: '1',
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('renders other "checkboxes" component for item', () => {
|
|
376
|
+
const faker = templateFaker();
|
|
377
|
+
const checkboxesSpy = faker.spy('checkboxes');
|
|
378
|
+
|
|
379
|
+
faker.renderComponent('checkboxes/checkbox', {
|
|
380
|
+
...EXAMPLE_CHECKBOX,
|
|
381
|
+
...EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
expect(checkboxesSpy.occurrences).toContainEqual({
|
|
385
|
+
id: 'example-checkboxes',
|
|
386
|
+
name: 'example-checkboxes-name',
|
|
387
|
+
checked: undefined,
|
|
388
|
+
borderlessParent: false,
|
|
389
|
+
borderless: true,
|
|
390
|
+
legend: 'Select preferred times of day',
|
|
391
|
+
legendClasses: 'extra-legend-class',
|
|
392
|
+
attributes: { a: 42 },
|
|
393
|
+
classes: 'ons-js-other-fieldset',
|
|
394
|
+
checkboxes: EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES.other.checkboxes,
|
|
395
|
+
autoSelect: EXAMPLE_CHECKBOXES_ITEM_CHECKBOXES.other.autoSelect,
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('renders other "radios" component for item', () => {
|
|
400
|
+
const faker = templateFaker();
|
|
401
|
+
const radiosSpy = faker.spy('radios');
|
|
402
|
+
|
|
403
|
+
faker.renderComponent('checkboxes/checkbox', {
|
|
404
|
+
...EXAMPLE_CHECKBOX,
|
|
405
|
+
...EXAMPLE_CHECKBOXES_ITEM_RADIOS,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
expect(radiosSpy.occurrences).toContainEqual({
|
|
409
|
+
id: 'example-radios',
|
|
410
|
+
name: 'example-radios-name',
|
|
411
|
+
borderless: true,
|
|
412
|
+
legend: 'Select preferred times of day',
|
|
413
|
+
legendClasses: 'extra-legend-class',
|
|
414
|
+
attributes: { a: 42 },
|
|
415
|
+
classes: 'ons-js-other-fieldset',
|
|
416
|
+
radios: EXAMPLE_CHECKBOXES_ITEM_RADIOS.other.radios,
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
});
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
{% set exclusiveClass = ' ons-js-exclusive-group-item' %}
|
|
38
38
|
{% endif %}
|
|
39
39
|
{% if params.borderless is defined and params.borderless %}
|
|
40
|
-
{% set borderless = "ons-checkbox--no-border" %}
|
|
40
|
+
{% set borderless = " ons-checkbox--no-border" %}
|
|
41
41
|
{% endif %}
|
|
42
42
|
{% if checkbox.other is defined and checkbox.other %}
|
|
43
43
|
{% set otherClass = " ons-js-other" %}
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
{% if params.mutuallyExclusive is defined and params.mutuallyExclusive %}
|
|
107
107
|
{% call onsMutuallyExclusive({
|
|
108
108
|
"id": params.id,
|
|
109
|
-
"description": params.description,
|
|
110
109
|
"classes": params.classes,
|
|
111
110
|
"legend": params.legend,
|
|
112
111
|
"legendClasses": params.legendClasses,
|
|
@@ -126,7 +125,6 @@
|
|
|
126
125
|
{% else %}
|
|
127
126
|
{% call onsFieldset({
|
|
128
127
|
"id": params.id,
|
|
129
|
-
"description": params.description,
|
|
130
128
|
"classes": params.classes,
|
|
131
129
|
"legend": params.legend,
|
|
132
130
|
"legendClasses": params.legendClasses,
|