@ons/design-system 67.2.0 → 68.0.1
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/_field-group.scss +3 -4
- 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 +17 -13
- 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 +3 -3
- 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 +128 -14
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -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
|
@@ -64,14 +64,14 @@ describe('script: radios', () => {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('radios with other options should be given aria-expanded attributes', async () => {
|
|
67
|
-
const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
|
|
67
|
+
const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
|
|
68
68
|
expect(ariaExpandedOption1).toBe('false');
|
|
69
|
-
const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
|
|
69
|
+
const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
|
|
70
70
|
expect(ariaExpandedOption2).toBe('false');
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('radios with "open" other options should not be given aria-expanded attributes', async () => {
|
|
74
|
-
const hasAriaExpandedOption3 = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
|
|
74
|
+
const hasAriaExpandedOption3 = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
|
|
75
75
|
expect(hasAriaExpandedOption3).toBe(false);
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -81,27 +81,27 @@ describe('script: radios', () => {
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
it('then the checked radio aria-expanded attribute should be set to true', async () => {
|
|
84
|
-
const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
|
|
84
|
+
const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
|
|
85
85
|
expect(ariaExpandedOption1).toBe('true');
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
|
|
89
|
-
const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
|
|
89
|
+
const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
|
|
90
90
|
expect(ariaExpandedOption2).toBe('false');
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
|
|
94
|
-
const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
|
|
94
|
+
const hasAriaExpanded = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
|
|
95
95
|
expect(hasAriaExpanded).toBe(false);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
it('then the clear button should be visible', async () => {
|
|
99
|
-
const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
|
|
99
|
+
const isHidden = await page.$eval('.ons-js-clear-btn', (node) => node.classList.contains('ons-u-db-no-js_enabled'));
|
|
100
100
|
expect(isHidden).toBe(false);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('then the aria live message should announce that the answer can be cleared', async () => {
|
|
104
|
-
const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
|
|
104
|
+
const alertText = await page.$eval('.ons-js-clear-radio-alert', (node) => node.innerHTML);
|
|
105
105
|
expect(alertText).toBe('You can clear your answer by clicking the clear selection button under the radio buttons');
|
|
106
106
|
});
|
|
107
107
|
|
|
@@ -111,17 +111,17 @@ describe('script: radios', () => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it('then the checked radio aria-expanded attribute should be set to true', async () => {
|
|
114
|
-
const ariaExpandedOption2 = await page.$eval('#phone', node => node.getAttribute('aria-expanded'));
|
|
114
|
+
const ariaExpandedOption2 = await page.$eval('#phone', (node) => node.getAttribute('aria-expanded'));
|
|
115
115
|
expect(ariaExpandedOption2).toBe('true');
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
it('then the unchecked radio aria-expanded attribute should be set to false', async () => {
|
|
119
|
-
const ariaExpandedOption1 = await page.$eval('#email', node => node.getAttribute('aria-expanded'));
|
|
119
|
+
const ariaExpandedOption1 = await page.$eval('#email', (node) => node.getAttribute('aria-expanded'));
|
|
120
120
|
expect(ariaExpandedOption1).toBe('false');
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
it('then the unchecked radio aria-expanded attribute of "open" radio should not be set', async () => {
|
|
124
|
-
const hasAriaExpanded = await page.$eval('#text', node => node.hasAttribute('aria-expanded'));
|
|
124
|
+
const hasAriaExpanded = await page.$eval('#text', (node) => node.hasAttribute('aria-expanded'));
|
|
125
125
|
expect(hasAriaExpanded).toBe(false);
|
|
126
126
|
});
|
|
127
127
|
});
|
|
@@ -129,30 +129,30 @@ describe('script: radios', () => {
|
|
|
129
129
|
|
|
130
130
|
describe('the clear button is clicked', () => {
|
|
131
131
|
beforeEach(async () => {
|
|
132
|
-
await page.$eval('.ons-js-clear-btn', node => node.click());
|
|
132
|
+
await page.$eval('.ons-js-clear-btn', (node) => node.click());
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
it('then the clear button should not be visible', async () => {
|
|
136
|
-
const isHidden = await page.$eval('.ons-js-clear-btn', node => node.classList.contains('ons-u-db-no-js_enabled'));
|
|
136
|
+
const isHidden = await page.$eval('.ons-js-clear-btn', (node) => node.classList.contains('ons-u-db-no-js_enabled'));
|
|
137
137
|
expect(isHidden).toBe(true);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
it('then the aria live message should announce that the answer has been cleared', async () => {
|
|
141
|
-
const alertText = await page.$eval('.ons-js-clear-radio-alert', node => node.innerHTML);
|
|
141
|
+
const alertText = await page.$eval('.ons-js-clear-radio-alert', (node) => node.innerHTML);
|
|
142
142
|
expect(alertText).toBe('You have cleared your answer');
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
it('then all radios should not be checked', async () => {
|
|
146
|
-
const checkedRadios = await page.$$eval('.ons-js-radio', nodes => nodes.map(node => node.checked));
|
|
146
|
+
const checkedRadios = await page.$$eval('.ons-js-radio', (nodes) => nodes.map((node) => node.checked));
|
|
147
147
|
expect(checkedRadios).not.toContain(true);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
it('then all other input fields should be empty', async () => {
|
|
151
|
-
const emailOtherValue = await page.$eval('#email-other', node => node.value);
|
|
151
|
+
const emailOtherValue = await page.$eval('#email-other', (node) => node.value);
|
|
152
152
|
expect(emailOtherValue).toBe('');
|
|
153
|
-
const telOtherValue = await page.$eval('#tel-other', node => node.value);
|
|
153
|
+
const telOtherValue = await page.$eval('#tel-other', (node) => node.value);
|
|
154
154
|
expect(telOtherValue).toBe('');
|
|
155
|
-
const textOtherValue = await page.$eval('#text-other', node => node.value);
|
|
155
|
+
const textOtherValue = await page.$eval('#text-other', (node) => node.value);
|
|
156
156
|
expect(textOtherValue).toBe('');
|
|
157
157
|
});
|
|
158
158
|
});
|
|
@@ -163,7 +163,7 @@ describe('script: radios', () => {
|
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
it('then the radio button should be checked', async () => {
|
|
166
|
-
const isRadioChecked = await page.$eval('#text', node => node.checked);
|
|
166
|
+
const isRadioChecked = await page.$eval('#text', (node) => node.checked);
|
|
167
167
|
expect(isRadioChecked).toBe(true);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
@@ -174,13 +174,13 @@ describe('script: radios', () => {
|
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
it('then the input should have a tab index of 0', async () => {
|
|
177
|
-
const tabIndex = await page.$eval('#text-other', node => node.getAttribute('tabindex'));
|
|
177
|
+
const tabIndex = await page.$eval('#text-other', (node) => node.getAttribute('tabindex'));
|
|
178
178
|
expect(tabIndex).toBe('0');
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
describe('reveal and fieldset', function() {
|
|
183
|
+
describe('reveal and fieldset', function () {
|
|
184
184
|
const params = {
|
|
185
185
|
legend: 'What are your favourite pizza toppings?',
|
|
186
186
|
name: 'food-other',
|
|
@@ -237,7 +237,7 @@ describe('script: radios', () => {
|
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
it('radios with other options should be given aria-expanded attributes', async () => {
|
|
240
|
-
const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
|
|
240
|
+
const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
|
|
241
241
|
expect(ariaExpanded).toBe('false');
|
|
242
242
|
});
|
|
243
243
|
|
|
@@ -247,7 +247,7 @@ describe('script: radios', () => {
|
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
it('has aria-expanded attribute should be set to true', async () => {
|
|
250
|
-
const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
|
|
250
|
+
const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
|
|
251
251
|
expect(ariaExpanded).toBe('true');
|
|
252
252
|
});
|
|
253
253
|
|
|
@@ -257,7 +257,7 @@ describe('script: radios', () => {
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
it('the radio with an other input aria-expanded attribute changes', async () => {
|
|
260
|
-
const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
|
|
260
|
+
const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
|
|
261
261
|
expect(ariaExpanded).toBe('false');
|
|
262
262
|
});
|
|
263
263
|
});
|
|
@@ -273,12 +273,12 @@ describe('script: radios', () => {
|
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
it('the other radio aria-expanded attribute should be set to false', async () => {
|
|
276
|
-
const ariaExpanded = await page.$eval('#other-radio', node => node.getAttribute('aria-expanded'));
|
|
276
|
+
const ariaExpanded = await page.$eval('#other-radio', (node) => node.getAttribute('aria-expanded'));
|
|
277
277
|
expect(ariaExpanded).toBe('false');
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
it('the child of other checkbox should be unchecked', async () => {
|
|
281
|
-
const innerInputChecked = await page.$eval('#inner-bacon-other', node => node.checked);
|
|
281
|
+
const innerInputChecked = await page.$eval('#inner-bacon-other', (node) => node.checked);
|
|
282
282
|
expect(innerInputChecked).toBe(false);
|
|
283
283
|
});
|
|
284
284
|
});
|
|
@@ -82,9 +82,7 @@ describe('macro: related-content', () => {
|
|
|
82
82
|
it('calls with content', () => {
|
|
83
83
|
const $ = cheerio.load(renderComponent('related-content', { EXAMPLE_RELATED_CONTENT_GENERAL }, 'Example content...'));
|
|
84
84
|
|
|
85
|
-
const content = $('.ons-related-content')
|
|
86
|
-
.text()
|
|
87
|
-
.trim();
|
|
85
|
+
const content = $('.ons-related-content').text().trim();
|
|
88
86
|
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
89
87
|
});
|
|
90
88
|
});
|
|
@@ -105,7 +103,7 @@ describe('macro: related-content', () => {
|
|
|
105
103
|
it('has the `aria-labelledby` attribute for each section of links', () => {
|
|
106
104
|
const $ = cheerio.load(renderComponent('related-content', EXAMPLE_RELATED_CONTENT_LINKS));
|
|
107
105
|
|
|
108
|
-
const values = mapAll($('.ons-related-content__navigation'), node => node.attr('aria-labelledby'));
|
|
106
|
+
const values = mapAll($('.ons-related-content__navigation'), (node) => node.attr('aria-labelledby'));
|
|
109
107
|
expect(values).toEqual(['related-articles', 'related-links']);
|
|
110
108
|
});
|
|
111
109
|
|
|
@@ -20,11 +20,7 @@ describe('macro: related-content/section', () => {
|
|
|
20
20
|
|
|
21
21
|
it('has the provided `title` text', () => {
|
|
22
22
|
const $ = cheerio.load(renderComponent('related-content/section', EXAMPLE_RELATED_SECTION_CONTENT));
|
|
23
|
-
expect(
|
|
24
|
-
$('.ons-related-content__title')
|
|
25
|
-
.text()
|
|
26
|
-
.trim(),
|
|
27
|
-
).toEqual('Related information');
|
|
23
|
+
expect($('.ons-related-content__title').text().trim()).toEqual('Related information');
|
|
28
24
|
});
|
|
29
25
|
|
|
30
26
|
it('has the `id` attribute for the title', () => {
|
|
@@ -35,9 +31,7 @@ describe('macro: related-content/section', () => {
|
|
|
35
31
|
it('has the provided content', () => {
|
|
36
32
|
const $ = cheerio.load(renderComponent('related-content/section', { EXAMPLE_RELATED_SECTION_CONTENT }, 'Example content...'));
|
|
37
33
|
|
|
38
|
-
const content = $('.ons-related-content__content')
|
|
39
|
-
.text()
|
|
40
|
-
.trim();
|
|
34
|
+
const content = $('.ons-related-content__content').text().trim();
|
|
41
35
|
expect(content).toEqual(expect.stringContaining('Example content...'));
|
|
42
36
|
});
|
|
43
37
|
});
|
|
@@ -25,24 +25,22 @@ layout: ~
|
|
|
25
25
|
|
|
26
26
|
{% block main %}
|
|
27
27
|
|
|
28
|
-
{% call
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
}}
|
|
28
|
+
{% call onsPanel({
|
|
29
|
+
"title": "There is a problem with your answer",
|
|
30
|
+
"variant": "error"
|
|
31
|
+
}) %}
|
|
32
|
+
{{
|
|
33
|
+
onsList({
|
|
34
|
+
"element": "ol",
|
|
35
|
+
"itemsList": [
|
|
36
|
+
{
|
|
37
|
+
"text": "Select a relationship",
|
|
38
|
+
"url": "#relationship-error",
|
|
39
|
+
"variants": "inPageLink"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
}}
|
|
46
44
|
{% endcall %}
|
|
47
45
|
{% call onsQuestion({
|
|
48
46
|
"title": "Thinking of Joe Bloggs, Amanda Bloggs is their <strong>…</strong>",
|
|
@@ -7,7 +7,7 @@ export default class Relationships {
|
|
|
7
7
|
this.radios = [...context.querySelectorAll('input[type=radio]')];
|
|
8
8
|
this.playback = context.querySelector('.ons-js-relationships-playback');
|
|
9
9
|
|
|
10
|
-
this.radios.forEach(radio => radio.addEventListener('change', this.setPlayback.bind(this)));
|
|
10
|
+
this.radios.forEach((radio) => radio.addEventListener('change', this.setPlayback.bind(this)));
|
|
11
11
|
|
|
12
12
|
this.setPlayback();
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ export default class Relationships {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
setPlayback() {
|
|
18
|
-
const radio = this.radios.find(radio => radio.checked);
|
|
18
|
+
const radio = this.radios.find((radio) => radio.checked);
|
|
19
19
|
|
|
20
20
|
if (radio) {
|
|
21
21
|
const title = radio.getAttribute('data-title');
|
|
@@ -13,9 +13,9 @@ const EXAMPLE_TEXTAREA = {
|
|
|
13
13
|
description: 'Reply description',
|
|
14
14
|
},
|
|
15
15
|
charCheckLimit: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
limit: 300,
|
|
17
|
+
charCountSingular: '{x} more character needed',
|
|
18
|
+
charCountPlural: '{x} more characters needed',
|
|
19
19
|
},
|
|
20
20
|
rows: 5,
|
|
21
21
|
};
|
|
@@ -29,7 +29,7 @@ describe('script: reply', () => {
|
|
|
29
29
|
|
|
30
30
|
it('the button has classes applied', async () => {
|
|
31
31
|
await setTestPage('/test', renderComponent('reply', EXAMPLE_REPLY));
|
|
32
|
-
const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
|
|
32
|
+
const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
|
|
33
33
|
expect(disabledButton).toBe(true);
|
|
34
34
|
});
|
|
35
35
|
});
|
|
@@ -49,7 +49,7 @@ describe('script: reply', () => {
|
|
|
49
49
|
await page.focus('#reply-textarea');
|
|
50
50
|
await page.keyboard.type('Sausages');
|
|
51
51
|
|
|
52
|
-
const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
|
|
52
|
+
const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
|
|
53
53
|
expect(disabledButton).toBe(false);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
@@ -71,7 +71,7 @@ describe('script: reply', () => {
|
|
|
71
71
|
await page.keyboard.type('s');
|
|
72
72
|
await page.keyboard.press('Backspace');
|
|
73
73
|
|
|
74
|
-
const disabledButton = await page.$eval('#reply-button', element => element.classList.contains('ons-btn--disabled'));
|
|
74
|
+
const disabledButton = await page.$eval('#reply-button', (element) => element.classList.contains('ons-btn--disabled'));
|
|
75
75
|
expect(disabledButton).toBe(true);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{% macro onsSectionNavigation(params) %}
|
|
2
|
-
{% set headingLevel = params.headingLevel |
|
|
3
|
-
{% set sectionTitleHeadingLevel =
|
|
2
|
+
{% set headingLevel = params.headingLevel | default(2) %}
|
|
3
|
+
{% set sectionTitleHeadingLevel = headingLevel + 1 %}
|
|
4
4
|
<nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %} {% if params.classes %} {{ params.classes }} {% endif %}"{% if params.id %} id="{{ params.id }}"{% endif %} aria-labelledby="{{ params.hiddenTitleId | default("section-menu-nav-title")}}">
|
|
5
|
-
|
|
5
|
+
<h{{ headingLevel }} class="ons-u-vh" id="{{ params.hiddenTitleId | default("section-menu-nav-title") }}">{{ params.hiddenTitle | default("Pages in this section") }}</h{{ headingLevel }}>
|
|
6
6
|
{% if params.sections %}
|
|
7
7
|
{% for section in params.sections %}
|
|
8
|
-
{% set sectionItemHeadingLevel =
|
|
8
|
+
{% set sectionItemHeadingLevel = headingLevel + 2 if section.title else headingLevel + 1 %}
|
|
9
9
|
<div class="ons-section-nav__sub">
|
|
10
10
|
{% if section.title %}
|
|
11
11
|
<h{{ sectionTitleHeadingLevel }} class="ons-u-fs-r--b ons-u-mb-s">{{ section.title }}</h{{ sectionTitleHeadingLevel }}>
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
{% set isCurrent = false %}
|
|
19
19
|
{% endif %}
|
|
20
20
|
<li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
{% if isCurrent == true %}
|
|
22
|
+
<h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ sectionItemHeadingLevel }}>
|
|
23
|
+
{% else %}
|
|
24
|
+
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
|
|
25
|
+
{% endif %}
|
|
26
|
+
{% if item.anchors and isCurrent == true %}
|
|
27
27
|
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
|
|
28
28
|
{% for anchor in item.anchors %}
|
|
29
29
|
<li class="ons-section-nav__item ons-list__item">
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
{% endif %}
|
|
44
44
|
<ul class="ons-section-nav__list">
|
|
45
45
|
{% for item in params.itemsList %}
|
|
46
|
-
{% set sectionItemHeadingLevel =
|
|
46
|
+
{% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
|
|
47
47
|
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title|lower) %}
|
|
48
48
|
{% set isCurrent = true %}
|
|
49
49
|
{% else %}
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
{% endif %}
|
|
52
52
|
<li class="ons-section-nav__item{% if item.classes %}{{ ' ' + item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
|
|
53
53
|
{% if isCurrent == true %}
|
|
54
|
-
<h{{ sectionItemHeadingLevel}} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
|
|
54
|
+
<h{{ sectionItemHeadingLevel }} class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location">{{ item.title }}</h{{ headingLevel + 2 if section.title else headingLevel + 1 }}>
|
|
55
55
|
{% else %}
|
|
56
56
|
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
|
|
57
57
|
{% endif %}
|
|
@@ -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';
|