@ons/design-system 68.0.0 → 70.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 +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +15 -11
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +2 -2
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +9 -9
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +8 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +1 -1
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +15 -14
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- package/components/date-field-input/_macro.njk +0 -86
|
@@ -145,10 +145,10 @@ describe('macro: section-navigation', () => {
|
|
|
145
145
|
it('renders top level navigation items', () => {
|
|
146
146
|
const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
|
|
147
147
|
|
|
148
|
-
const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
|
|
148
|
+
const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
|
|
149
149
|
expect(itemLabels).toEqual(['Results', 'Dashboard']);
|
|
150
150
|
|
|
151
|
-
const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.attr('href'));
|
|
151
|
+
const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.attr('href'));
|
|
152
152
|
expect(itemLinks).toEqual(['/results', '/results/dashboard']);
|
|
153
153
|
});
|
|
154
154
|
|
|
@@ -173,11 +173,7 @@ describe('macro: section-navigation', () => {
|
|
|
173
173
|
it('marks the current item with a class when `currentPath` is provided', () => {
|
|
174
174
|
const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
|
|
175
175
|
|
|
176
|
-
expect(
|
|
177
|
-
$('.ons-section-nav__item--active')
|
|
178
|
-
.text()
|
|
179
|
-
.trim(),
|
|
180
|
-
).toBe('Results');
|
|
176
|
+
expect($('.ons-section-nav__item--active').text().trim()).toBe('Results');
|
|
181
177
|
});
|
|
182
178
|
|
|
183
179
|
it('marks the current item with a class when `tabQuery` is provided', () => {
|
|
@@ -189,11 +185,7 @@ describe('macro: section-navigation', () => {
|
|
|
189
185
|
}),
|
|
190
186
|
);
|
|
191
187
|
|
|
192
|
-
expect(
|
|
193
|
-
$('.ons-section-nav__item--active')
|
|
194
|
-
.text()
|
|
195
|
-
.trim(),
|
|
196
|
-
).toBe('Dashboard');
|
|
188
|
+
expect($('.ons-section-nav__item--active').text().trim()).toBe('Dashboard');
|
|
197
189
|
});
|
|
198
190
|
|
|
199
191
|
it('marks the current item with `aria-current` when `currentPath` is provided', () => {
|
|
@@ -226,12 +218,14 @@ describe('macro: section-navigation', () => {
|
|
|
226
218
|
it('renders the expected anchor navigation items', () => {
|
|
227
219
|
const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL));
|
|
228
220
|
|
|
229
|
-
const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node =>
|
|
221
|
+
const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
|
|
230
222
|
node.text().trim(),
|
|
231
223
|
);
|
|
232
224
|
expect(itemLabels).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
|
|
233
225
|
|
|
234
|
-
const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node =>
|
|
226
|
+
const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
|
|
227
|
+
node.attr('href'),
|
|
228
|
+
);
|
|
235
229
|
expect(itemLinks).toEqual(['#sub-section-1', '#sub-section-2', '#sub-section-3']);
|
|
236
230
|
});
|
|
237
231
|
});
|
|
@@ -247,17 +241,15 @@ describe('macro: section-navigation', () => {
|
|
|
247
241
|
it('renders itemsLists, anchors and heading for each section', () => {
|
|
248
242
|
const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL_WITH_SECTIONS));
|
|
249
243
|
|
|
250
|
-
const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node =>
|
|
244
|
+
const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
|
|
245
|
+
node.text().trim(),
|
|
246
|
+
);
|
|
251
247
|
expect(anchors).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
|
|
252
248
|
|
|
253
|
-
const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
|
|
249
|
+
const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
|
|
254
250
|
expect(itemLists).toEqual(['Section 1', 'Section 2', 'Sub section 1', 'Sub section 2', 'Sub section 3', 'Section 3']);
|
|
255
251
|
|
|
256
|
-
const headings = mapAll($('h3'), node =>
|
|
257
|
-
$(node)
|
|
258
|
-
.text()
|
|
259
|
-
.trim(),
|
|
260
|
-
);
|
|
252
|
+
const headings = mapAll($('h3'), (node) => $(node).text().trim());
|
|
261
253
|
expect(headings).toEqual(['Section Title']);
|
|
262
254
|
});
|
|
263
255
|
});
|
|
@@ -155,35 +155,35 @@ describe('macro: select', () => {
|
|
|
155
155
|
it('has expected text', () => {
|
|
156
156
|
const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
|
|
157
157
|
|
|
158
|
-
const values = mapAll($('select > option'), node => node.text().trim());
|
|
158
|
+
const values = mapAll($('select > option'), (node) => node.text().trim());
|
|
159
159
|
expect(values).toEqual(['First option', 'Second option', 'Disabled option']);
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('has a provided `id` attribute', () => {
|
|
163
163
|
const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
|
|
164
164
|
|
|
165
|
-
const values = mapAll($('select > option'), node => node.attr('id'));
|
|
165
|
+
const values = mapAll($('select > option'), (node) => node.attr('id'));
|
|
166
166
|
expect(values).toEqual([undefined, 'second-option', undefined]);
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
it('marks the correct option as selected', () => {
|
|
170
170
|
const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
|
|
171
171
|
|
|
172
|
-
const values = mapAll($('select > option'), node => node.attr('selected'));
|
|
172
|
+
const values = mapAll($('select > option'), (node) => node.attr('selected'));
|
|
173
173
|
expect(values).toEqual([undefined, 'selected', undefined]);
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
it('marks the correct option as disabled', () => {
|
|
177
177
|
const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
|
|
178
178
|
|
|
179
|
-
const values = mapAll($('select > option'), node => node.attr('disabled'));
|
|
179
|
+
const values = mapAll($('select > option'), (node) => node.attr('disabled'));
|
|
180
180
|
expect(values).toEqual([undefined, undefined, 'disabled']);
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
it('has a provided `value` attribute', () => {
|
|
184
184
|
const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
|
|
185
185
|
|
|
186
|
-
const values = mapAll($('select > option'), node => node.attr('value'));
|
|
186
|
+
const values = mapAll($('select > option'), (node) => node.attr('value'));
|
|
187
187
|
expect(values).toEqual(['1', '2', '3']);
|
|
188
188
|
});
|
|
189
189
|
|
|
@@ -195,7 +195,7 @@ describe('macro: select', () => {
|
|
|
195
195
|
}),
|
|
196
196
|
);
|
|
197
197
|
|
|
198
|
-
const values = mapAll($('select > option'), node => node.attr('value'));
|
|
198
|
+
const values = mapAll($('select > option'), (node) => node.attr('value'));
|
|
199
199
|
expect(values).toEqual(['First option', 'Second option']);
|
|
200
200
|
});
|
|
201
201
|
});
|
|
@@ -24,11 +24,7 @@ describe('macro: share-page', () => {
|
|
|
24
24
|
it('wraps title in <h2> element by default', () => {
|
|
25
25
|
const $ = cheerio.load(renderComponent('share-page', EXAMPLE_SHARE_PAGE));
|
|
26
26
|
|
|
27
|
-
expect(
|
|
28
|
-
$('h2')
|
|
29
|
-
.text()
|
|
30
|
-
.trim(),
|
|
31
|
-
).toBe('Share page');
|
|
27
|
+
expect($('h2').text().trim()).toBe('Share page');
|
|
32
28
|
});
|
|
33
29
|
|
|
34
30
|
it('wraps title in custom element when `titleTag` is provided', () => {
|
|
@@ -39,11 +35,7 @@ describe('macro: share-page', () => {
|
|
|
39
35
|
}),
|
|
40
36
|
);
|
|
41
37
|
|
|
42
|
-
expect(
|
|
43
|
-
$('h4')
|
|
44
|
-
.text()
|
|
45
|
-
.trim(),
|
|
46
|
-
).toBe('Share page');
|
|
38
|
+
expect($('h4').text().trim()).toBe('Share page');
|
|
47
39
|
});
|
|
48
40
|
|
|
49
41
|
it('uses the provided icon size', () => {
|
|
@@ -65,7 +57,7 @@ describe('macro: share-page', () => {
|
|
|
65
57
|
|
|
66
58
|
faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
|
|
67
59
|
|
|
68
|
-
const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
|
|
60
|
+
const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
|
|
69
61
|
expect(twitterItem.url).toBe(
|
|
70
62
|
'https://twitter.com/intent/tweet?original_referer&text=An%20example%20page&url=https%3A%2F%2Fexample.com%2Fan-example-page',
|
|
71
63
|
);
|
|
@@ -77,7 +69,7 @@ describe('macro: share-page', () => {
|
|
|
77
69
|
|
|
78
70
|
faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
|
|
79
71
|
|
|
80
|
-
const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
|
|
72
|
+
const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
|
|
81
73
|
expect(twitterItem.rel).toContain('noreferrer');
|
|
82
74
|
expect(twitterItem.rel).toContain('external');
|
|
83
75
|
expect(twitterItem.target).toBe('_blank');
|
|
@@ -91,7 +83,7 @@ describe('macro: share-page', () => {
|
|
|
91
83
|
|
|
92
84
|
faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
|
|
93
85
|
|
|
94
|
-
const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
|
|
86
|
+
const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
|
|
95
87
|
expect(facebookItem.url).toBe('https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fexample.com%2Fan-example-page');
|
|
96
88
|
});
|
|
97
89
|
|
|
@@ -101,7 +93,7 @@ describe('macro: share-page', () => {
|
|
|
101
93
|
|
|
102
94
|
faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
|
|
103
95
|
|
|
104
|
-
const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
|
|
96
|
+
const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
|
|
105
97
|
expect(facebookItem.rel).toContain('noreferrer');
|
|
106
98
|
expect(facebookItem.rel).toContain('external');
|
|
107
99
|
expect(facebookItem.target).toBe('_blank');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
4
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
|
-
import { renderComponent
|
|
6
|
+
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
8
|
describe('macro: skip-to-content', () => {
|
|
9
9
|
it('passes jest-axe checks', async () => {
|
|
@@ -48,11 +48,7 @@ describe('macro: skip-to-content', () => {
|
|
|
48
48
|
}),
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
expect(
|
|
52
|
-
$('.ons-skip-to-content')
|
|
53
|
-
.text()
|
|
54
|
-
.trim(),
|
|
55
|
-
).toBe('Skip to the content');
|
|
51
|
+
expect($('.ons-skip-to-content').text().trim()).toBe('Skip to the content');
|
|
56
52
|
});
|
|
57
53
|
|
|
58
54
|
it('has skip link with the default text if no text provided`', async () => {
|
|
@@ -62,10 +58,6 @@ describe('macro: skip-to-content', () => {
|
|
|
62
58
|
}),
|
|
63
59
|
);
|
|
64
60
|
|
|
65
|
-
expect(
|
|
66
|
-
$('.ons-skip-to-content')
|
|
67
|
-
.text()
|
|
68
|
-
.trim(),
|
|
69
|
-
).toBe('Skip to content');
|
|
61
|
+
expect($('.ons-skip-to-content').text().trim()).toBe('Skip to content');
|
|
70
62
|
});
|
|
71
63
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function skipToMain(link) {
|
|
2
2
|
const id = link.getAttribute('href').replace('#', '');
|
|
3
|
-
link.addEventListener('click', event => {
|
|
3
|
+
link.addEventListener('click', (event) => {
|
|
4
4
|
event.preventDefault();
|
|
5
5
|
document.getElementById(id).tabIndex = -1;
|
|
6
6
|
document.getElementById(id).style.outline = 'none';
|
|
@@ -18,7 +18,7 @@ describe('script: skip-to-content', () => {
|
|
|
18
18
|
await page.focus('.ons-skip-to-content');
|
|
19
19
|
await page.keyboard.press('Enter');
|
|
20
20
|
|
|
21
|
-
const targetTabIndex = await page.$eval('#target-element', el => el.tabIndex);
|
|
21
|
+
const targetTabIndex = await page.$eval('#target-element', (el) => el.tabIndex);
|
|
22
22
|
expect(targetTabIndex).toBe(-1);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ describe('script: skip-to-content', () => {
|
|
|
28
28
|
await page.focus('.ons-skip-to-content');
|
|
29
29
|
await page.keyboard.press('Enter');
|
|
30
30
|
|
|
31
|
-
const targetOutline = await page.$eval('#target-element', el => el.style.outline);
|
|
31
|
+
const targetOutline = await page.$eval('#target-element', (el) => el.style.outline);
|
|
32
32
|
expect(targetOutline).toBe('none');
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -9,7 +9,7 @@ describe('macro: status', () => {
|
|
|
9
9
|
it('passes jest-axe checks', async () => {
|
|
10
10
|
const $ = cheerio.load(
|
|
11
11
|
renderComponent('status', {
|
|
12
|
-
|
|
12
|
+
variant: 'success',
|
|
13
13
|
label: 'Example status message',
|
|
14
14
|
size: 'small',
|
|
15
15
|
}),
|
|
@@ -19,7 +19,7 @@ describe('macro: status', () => {
|
|
|
19
19
|
expect(results).toHaveNoViolations();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it('has the default
|
|
22
|
+
it('has the default variant "info" when `variant` is not provided', () => {
|
|
23
23
|
const $ = cheerio.load(
|
|
24
24
|
renderComponent('status', {
|
|
25
25
|
label: 'Example status message',
|
|
@@ -29,10 +29,10 @@ describe('macro: status', () => {
|
|
|
29
29
|
expect($('.ons-status').hasClass('ons-status--info')).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
it('has the provided `
|
|
32
|
+
it('has the provided `variant`', () => {
|
|
33
33
|
const $ = cheerio.load(
|
|
34
34
|
renderComponent('status', {
|
|
35
|
-
|
|
35
|
+
variant: 'success',
|
|
36
36
|
label: 'Example status message',
|
|
37
37
|
}),
|
|
38
38
|
);
|
|
@@ -68,10 +68,6 @@ describe('macro: status', () => {
|
|
|
68
68
|
}),
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
expect(
|
|
72
|
-
$('.ons-status')
|
|
73
|
-
.text()
|
|
74
|
-
.trim(),
|
|
75
|
-
).toBe('Example status message');
|
|
71
|
+
expect($('.ons-status').text().trim()).toBe('Example status message');
|
|
76
72
|
});
|
|
77
73
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% macro onsSummary(params) %}
|
|
2
2
|
{% set className = "ons-summary" %}
|
|
3
|
-
{% set
|
|
3
|
+
{% set headingLevel = 2 %}
|
|
4
4
|
|
|
5
5
|
{% if params.variant == "hub" %}
|
|
6
6
|
{% set variantHub = true %}
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
{% for summary in params.summaries %}
|
|
18
18
|
{% if summary.summaryTitle %}
|
|
19
19
|
<h2 class="ons-summary__title ons-u-mb-m{{ " ons-u-mt-m" if loop.index > 1 else "" }}">{{ summary.summaryTitle }}</h2>
|
|
20
|
-
{% set
|
|
20
|
+
{% set headingLevel = 3 %}
|
|
21
21
|
{% endif %}
|
|
22
22
|
{% for group in summary.groups %}
|
|
23
23
|
<div {% if group.id %}id="{{ group.id }}" {% endif %} class="ons-summary__group{{ variantClasses }}">
|
|
24
24
|
{% if group.groupTitle %}
|
|
25
|
-
<h{{
|
|
25
|
+
<h{{ headingLevel }} class="ons-summary__group-title">{{ group.groupTitle }}</h{{ headingLevel }}>
|
|
26
26
|
{% endif %}
|
|
27
27
|
{% if group.rows %}
|
|
28
|
-
<
|
|
29
|
-
|
|
28
|
+
<dl class="ons-summary__items">
|
|
30
29
|
{% for row in group.rows %}
|
|
31
30
|
{% set itemClass = "" %}
|
|
32
31
|
{% if row.error %} {% set itemClass = " ons-summary__item--error" %}{% endif %}
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
{% endif %}
|
|
41
40
|
|
|
42
41
|
{% for rowItem in row.rowItems %}
|
|
43
|
-
<
|
|
42
|
+
<div class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}"{% if rowItem.id %} id="{{ rowItem.id }}"{% endif %}>
|
|
44
43
|
<dt class="ons-summary__item-title"
|
|
45
44
|
{% if rowItem.rowTitleAttributes %}{% for attribute, value in (rowItem.rowTitleAttributes.items() if rowItem.rowTitleAttributes is mapping and rowItem.rowTitleAttributes.items else rowItem.rowTitleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
|
|
46
45
|
>
|
|
@@ -104,11 +103,11 @@
|
|
|
104
103
|
{% endfor %}
|
|
105
104
|
</dd>
|
|
106
105
|
{% endif %}
|
|
107
|
-
</
|
|
106
|
+
</div>
|
|
108
107
|
{% endfor %}
|
|
109
108
|
</div>
|
|
110
109
|
{% endfor %}
|
|
111
|
-
</
|
|
110
|
+
</dl>
|
|
112
111
|
{% elif group.placeholderText %}
|
|
113
112
|
<span class="ons-summary__placeholder">{{ group.placeholderText }}</span>
|
|
114
113
|
{% endif %}
|
|
@@ -303,12 +303,26 @@ const EXAMPLE_SUMMARY_MULTIPLE_GROUPS = {
|
|
|
303
303
|
],
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
+
// To address a DAC issue, we've disabled specific axe definition list rules causing test failures.
|
|
307
|
+
// While resolving it would require a significant refactor, the failures are deemed non-critical for accessibility,
|
|
308
|
+
// leading to their removal in this context. [https://github.com/ONSdigital/design-system/issues/3027]
|
|
309
|
+
const axeRules = {
|
|
310
|
+
rules: {
|
|
311
|
+
dlitem: {
|
|
312
|
+
enabled: false,
|
|
313
|
+
},
|
|
314
|
+
'definition-list': {
|
|
315
|
+
enabled: false,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
|
|
306
320
|
describe('macro: summary', () => {
|
|
307
321
|
describe('mode: general', () => {
|
|
308
322
|
it('passes jest-axe checks', async () => {
|
|
309
323
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
324
|
+
const results = await axe($.html(), axeRules);
|
|
310
325
|
|
|
311
|
-
const results = await axe($.html());
|
|
312
326
|
expect(results).toHaveNoViolations();
|
|
313
327
|
});
|
|
314
328
|
|
|
@@ -436,15 +450,19 @@ describe('macro: summary', () => {
|
|
|
436
450
|
it('displays the `valueList` text', () => {
|
|
437
451
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
438
452
|
|
|
439
|
-
expect(
|
|
440
|
-
'
|
|
441
|
-
|
|
453
|
+
expect(
|
|
454
|
+
$('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__row .ons-summary__values .ons-summary__text')
|
|
455
|
+
.text()
|
|
456
|
+
.trim(),
|
|
457
|
+
).toBe('row value 1');
|
|
442
458
|
});
|
|
443
459
|
|
|
444
460
|
it('displays the `other` text', () => {
|
|
445
461
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
446
462
|
|
|
447
|
-
expect($('.ons-summary__items .ons-summary__item:nth-of-type(1)
|
|
463
|
+
expect($('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__row .ons-summary__values ul li').text().trim()).toBe(
|
|
464
|
+
'other value',
|
|
465
|
+
);
|
|
448
466
|
});
|
|
449
467
|
|
|
450
468
|
it('wraps the `valueList` in a ul if multiple values provided', () => {
|
|
@@ -516,8 +534,8 @@ describe('macro: summary', () => {
|
|
|
516
534
|
describe('mode: with title', () => {
|
|
517
535
|
it('passes jest-axe checks', async () => {
|
|
518
536
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_TITLE));
|
|
537
|
+
const results = await axe($.html(), axeRules);
|
|
519
538
|
|
|
520
|
-
const results = await axe($.html());
|
|
521
539
|
expect(results).toHaveNoViolations();
|
|
522
540
|
});
|
|
523
541
|
|
|
@@ -536,8 +554,8 @@ describe('macro: summary', () => {
|
|
|
536
554
|
variant: 'hub',
|
|
537
555
|
}),
|
|
538
556
|
);
|
|
557
|
+
const results = await axe($.html(), axeRules);
|
|
539
558
|
|
|
540
|
-
const results = await axe($.html());
|
|
541
559
|
expect(results).toHaveNoViolations();
|
|
542
560
|
});
|
|
543
561
|
|
|
@@ -570,7 +588,7 @@ describe('macro: summary', () => {
|
|
|
570
588
|
it('passes jest-axe checks', async () => {
|
|
571
589
|
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
572
590
|
|
|
573
|
-
const results = await axe($.html());
|
|
591
|
+
const results = await axe($.html(), axeRules);
|
|
574
592
|
expect(results).toHaveNoViolations();
|
|
575
593
|
});
|
|
576
594
|
|
|
@@ -609,8 +627,8 @@ describe('macro: summary', () => {
|
|
|
609
627
|
describe('mode: card', () => {
|
|
610
628
|
it('passes jest-axe checks', async () => {
|
|
611
629
|
const $ = cheerio.load(renderComponent('summary', { ...EXAMPLE_SUMMARY_BASIC, variant: 'card' }));
|
|
630
|
+
const results = await axe($.html(), axeRules);
|
|
612
631
|
|
|
613
|
-
const results = await axe($.html());
|
|
614
632
|
expect(results).toHaveNoViolations();
|
|
615
633
|
});
|
|
616
634
|
|
|
@@ -59,7 +59,7 @@ describe('macro: table', () => {
|
|
|
59
59
|
it('renders header cells with expected text', () => {
|
|
60
60
|
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
61
61
|
|
|
62
|
-
const headerCellValues = mapAll($('.ons-table__header'), node => node.text().trim());
|
|
62
|
+
const headerCellValues = mapAll($('.ons-table__header'), (node) => node.text().trim());
|
|
63
63
|
expect(headerCellValues).toEqual(['Column 1', 'Column 2', 'Column 3']);
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -121,7 +121,7 @@ describe('macro: table', () => {
|
|
|
121
121
|
it('does not add visually hidden class to column headers', () => {
|
|
122
122
|
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
123
123
|
|
|
124
|
-
const hasClass = mapAll($('.ons-table__header > span'), node => node.hasClass('ons-u-vh'));
|
|
124
|
+
const hasClass = mapAll($('.ons-table__header > span'), (node) => node.hasClass('ons-u-vh'));
|
|
125
125
|
expect(hasClass).toEqual([false, false, false]);
|
|
126
126
|
});
|
|
127
127
|
|
|
@@ -139,9 +139,9 @@ describe('macro: table', () => {
|
|
|
139
139
|
it('renders expected row cells', () => {
|
|
140
140
|
const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
|
|
141
141
|
|
|
142
|
-
const row1Values = mapAll($('.ons-table__row:nth-child(1) .ons-table__cell'), node => node.text().trim());
|
|
142
|
+
const row1Values = mapAll($('.ons-table__row:nth-child(1) .ons-table__cell'), (node) => node.text().trim());
|
|
143
143
|
expect(row1Values).toEqual(['Row 1 Cell 1', 'Row 1 Cell 2', 'Row 1 Cell 3']);
|
|
144
|
-
const row2Values = mapAll($('.ons-table__row:nth-child(2) .ons-table__cell'), node => node.text().trim());
|
|
144
|
+
const row2Values = mapAll($('.ons-table__row:nth-child(2) .ons-table__cell'), (node) => node.text().trim());
|
|
145
145
|
expect(row2Values).toEqual(['Row 2 Cell 1', 'Row 2 Cell 2', 'Row 2 Cell 3']);
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -401,7 +401,7 @@ describe('macro: table', () => {
|
|
|
401
401
|
}),
|
|
402
402
|
);
|
|
403
403
|
|
|
404
|
-
const footerCellValues = mapAll($('.ons-table__foot .ons-table__cell'), node => node.text().trim());
|
|
404
|
+
const footerCellValues = mapAll($('.ons-table__foot .ons-table__cell'), (node) => node.text().trim());
|
|
405
405
|
expect(footerCellValues).toEqual(['Footer Cell 1', 'Footer Cell 2', 'Footer Cell 3']);
|
|
406
406
|
});
|
|
407
407
|
});
|
|
@@ -515,11 +515,7 @@ describe('macro: table', () => {
|
|
|
515
515
|
}),
|
|
516
516
|
);
|
|
517
517
|
|
|
518
|
-
expect(
|
|
519
|
-
$('.ons-table__caption')
|
|
520
|
-
.text()
|
|
521
|
-
.trim(),
|
|
522
|
-
).toBe('Example table caption');
|
|
518
|
+
expect($('.ons-table__caption').text().trim()).toBe('Example table caption');
|
|
523
519
|
});
|
|
524
520
|
|
|
525
521
|
it('does not visually hide caption when `hideCaption` is not provided', () => {
|
|
@@ -65,7 +65,7 @@ export default class TableScroll {
|
|
|
65
65
|
? rightShadow.classList.remove('ons-visible')
|
|
66
66
|
: rightShadow.classList.add('ons-visible');
|
|
67
67
|
|
|
68
|
-
setTimeout(function() {
|
|
68
|
+
setTimeout(function () {
|
|
69
69
|
return leftShadow.classList.add('ons-with-transition'), rightShadow.classList.add('ons-with-transition');
|
|
70
70
|
}, 200);
|
|
71
71
|
}
|
|
@@ -59,7 +59,7 @@ export default class TableSort {
|
|
|
59
59
|
this.tableBody = this.table.getElementsByClassName(classTableBody);
|
|
60
60
|
const tableBody = [...this.tableBody];
|
|
61
61
|
|
|
62
|
-
tableBody.forEach(tbody => {
|
|
62
|
+
tableBody.forEach((tbody) => {
|
|
63
63
|
const rows = this.getTableRowsArray(tbody);
|
|
64
64
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
65
65
|
this.addRows(tbody, sortedRows);
|
|
@@ -74,7 +74,7 @@ export default class TableSort {
|
|
|
74
74
|
this.trs = tbody.querySelectorAll('tr');
|
|
75
75
|
const trs = [...this.trs];
|
|
76
76
|
|
|
77
|
-
trs.forEach(tr => {
|
|
77
|
+
trs.forEach((tr) => {
|
|
78
78
|
rows.push(tr);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -123,7 +123,7 @@ export default class TableSort {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
addRows(body, rows) {
|
|
126
|
-
rows.forEach(row => {
|
|
126
|
+
rows.forEach((row) => {
|
|
127
127
|
body.append(row);
|
|
128
128
|
});
|
|
129
129
|
}
|
|
@@ -131,7 +131,7 @@ export default class TableSort {
|
|
|
131
131
|
removeButtonStates() {
|
|
132
132
|
this.sortableHeadings = this.table.querySelectorAll(jsSortableHeadings);
|
|
133
133
|
const sortableHeadings = [...this.sortableHeadings];
|
|
134
|
-
sortableHeadings.forEach(heading => {
|
|
134
|
+
sortableHeadings.forEach((heading) => {
|
|
135
135
|
heading.setAttribute('aria-sort', 'none');
|
|
136
136
|
});
|
|
137
137
|
}
|