@ons/design-system 70.0.16 → 72.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 +10 -1
- package/components/access-code/_macro.njk +4 -4
- package/components/access-code/_macro.spec.js +10 -10
- package/components/access-code/example-access-code-error.njk +2 -2
- package/components/access-code/example-access-code.njk +2 -2
- package/components/accordion/_macro.njk +1 -1
- package/components/accordion/_macro.spec.js +162 -91
- package/components/accordion/_test_examples.js +13 -0
- package/components/address-input/_macro.njk +7 -7
- package/components/address-input/_macro.spec.js +16 -15
- package/components/address-input/autosuggest.address.error.js +1 -1
- package/components/address-input/autosuggest.address.js +25 -25
- package/components/address-input/autosuggest.address.spec.js +6 -5
- package/components/address-input/example-address-input-editable.njk +5 -4
- package/components/address-input/example-address-input.njk +4 -5
- package/components/autosuggest/_autosuggest.scss +8 -8
- package/components/autosuggest/_macro.njk +5 -5
- package/components/autosuggest/autosuggest.spec.js +1 -1
- package/components/back-to-top/_back-to-top.scss +2 -2
- package/components/back-to-top/_macro.spec.js +1 -1
- package/components/back-to-top/example-full-page-back-to-top.njk +6 -6
- package/components/breadcrumbs/_breadcrumbs.scss +1 -1
- package/components/breadcrumbs/_macro.spec.js +121 -115
- package/components/breadcrumbs/_test_examples.js +36 -0
- package/components/browser-banner/_macro.spec.js +1 -1
- package/components/button/_button.scss +24 -16
- package/components/button/_macro.njk +5 -5
- package/components/button/_macro.spec.js +2 -2
- package/components/button/example-button-custom.njk +1 -1
- package/components/card/_card.scss +0 -6
- package/components/card/_macro.njk +9 -9
- package/components/card/_macro.spec.js +57 -24
- package/components/card/example-card-set-with-images.njk +30 -18
- package/components/card/example-card-set-with-lists.njk +57 -45
- package/components/card/example-card-set.njk +27 -15
- package/components/card/example-card.njk +9 -5
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +4 -4
- package/components/checkboxes/_checkboxes.scss +1 -1
- package/components/checkboxes/example-checkboxes-with-hidden-label.njk +4 -4
- package/components/cookies-banner/_cookies-banner.scss +5 -5
- package/components/cookies-banner/_macro.njk +15 -13
- package/components/cookies-banner/_macro.spec.js +1 -1
- package/components/details/_details.scss +5 -6
- package/components/details/_macro.njk +4 -4
- package/components/details/_macro.spec.js +1 -1
- package/components/document-list/_document-list.scss +0 -2
- package/components/document-list/_macro.njk +18 -18
- package/components/document-list/_macro.spec.js +16 -14
- package/components/document-list/example-document-list-article-featured.njk +5 -3
- package/components/document-list/example-document-list-articles.njk +15 -9
- package/components/document-list/example-document-list-downloads.njk +15 -9
- package/components/document-list/example-document-list-search-result-featured.njk +5 -3
- package/components/document-list/example-document-list-search-results.njk +20 -12
- package/components/download-resources/_download-resources.scss +1 -2
- package/components/download-resources/download-resources.spec.js +12 -6
- package/components/external-link/_macro.njk +1 -1
- package/components/external-link/_macro.spec.js +1 -1
- package/components/external-link/example-external-link.njk +1 -1
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +3 -3
- package/components/feedback/example-feedback-call-to-action.njk +1 -1
- package/components/field/_field-group.scss +0 -2
- package/components/field/_field.scss +1 -2
- package/components/fieldset/_fieldset.scss +2 -2
- package/components/fieldset/_macro.njk +1 -1
- package/components/fieldset/_macro.spec.js +1 -1
- package/components/footer/_footer.scss +12 -7
- package/components/footer/_macro.njk +54 -34
- package/components/footer/_macro.spec.js +90 -28
- package/components/footer/example-footer-cymraeg.njk +1 -1
- package/components/footer/example-footer-transactional.njk +1 -1
- package/components/footer/example-footer-warning.njk +1 -1
- package/components/footer/example-footer-with-alternative-organisation.njk +99 -94
- package/components/footer/example-footer-with-coat-of-arms.njk +1 -1
- package/components/footer/example-footer-with-copyright.njk +1 -1
- package/components/footer/example-footer-with-multiple-logos-and-split-display.njk +173 -0
- package/components/footer/example-footer-with-multiple-logos.njk +172 -0
- package/components/footer/example-footer.njk +1 -1
- package/components/header/_header.scss +7 -14
- package/components/header/_macro.njk +19 -19
- package/components/header/_macro.spec.js +18 -18
- package/components/header/example-header-external-for-surveys.njk +2 -2
- package/components/header/example-header-external-welsh.njk +2 -2
- package/components/header/example-header-external-with-sub-navigation-removed.njk +1 -1
- package/components/header/example-header-external-with-sub-navigation.njk +1 -1
- package/components/header/example-header-multiple-logos.njk +4 -4
- package/components/hero/_hero.scss +6 -8
- package/components/hero/_macro.njk +1 -1
- package/components/icon/_icon.scss +4 -4
- package/components/icon/_macro.njk +4 -4
- package/components/icon/_macro.spec.js +2 -2
- package/components/image/_image.scss +1 -1
- package/components/image/_macro.njk +1 -1
- package/components/image/_macro.spec.js +10 -10
- package/components/image/example-image-for-regular-screens.njk +1 -1
- package/components/input/_input-type.scss +0 -2
- package/components/input/_input.scss +10 -10
- package/components/input/_macro.njk +4 -2
- package/components/input/example-input-search-with-character-check.njk +1 -1
- package/components/input/example-input-search.njk +1 -1
- package/components/label/_label.scss +1 -3
- package/components/language-selector/_macro.njk +3 -3
- package/components/language-selector/_macro.spec.js +7 -7
- package/components/list/_list.scss +1 -5
- package/components/list/_macro.njk +9 -10
- package/components/list/_macro.spec.js +50 -9
- package/components/list/example-inline-list-with-social-icon-prefix.njk +1 -1
- package/components/message/_macro.njk +3 -3
- package/components/message/_macro.spec.js +3 -3
- package/components/message-list/_macro.njk +2 -2
- package/components/message-list/_macro.spec.js +8 -4
- package/components/message-list/_message-list.scss +2 -2
- package/components/navigation/_macro.njk +9 -9
- package/components/navigation/_macro.spec.js +2 -2
- package/components/navigation/_navigation.scss +2 -6
- package/components/navigation/navigation.dom.js +1 -1
- package/components/navigation/navigation.spec.js +4 -4
- package/components/pagination/_macro.njk +2 -2
- package/components/pagination/_pagination.scss +1 -7
- package/components/panel/_macro.njk +5 -4
- package/components/panel/_macro.spec.js +2 -2
- package/components/panel/_panel.scss +12 -8
- package/components/password/_macro.njk +1 -1
- package/components/password/_macro.spec.js +2 -2
- package/components/phase-banner/_macro.njk +1 -1
- package/components/phase-banner/_phase-banner.scss +3 -4
- package/components/phase-banner/example-phase-banner-alpha.njk +1 -1
- package/components/phase-banner/example-phase-banner-beta.njk +1 -1
- package/components/question/_macro.njk +8 -8
- package/components/question/_macro.spec.js +3 -3
- package/components/question/_question.scss +3 -3
- package/components/radios/_macro.njk +1 -1
- package/components/radios/_macro.spec.js +1 -1
- package/components/radios/_radios.scss +1 -1
- package/components/radios/example-radios-with-clear-button-expanded.njk +1 -1
- package/components/radios/example-radios-with-clear-button.njk +1 -1
- package/components/related-content/_macro.spec.js +2 -2
- package/components/related-content/_related-content.scss +1 -1
- package/components/related-content/example-related-content-general.njk +2 -2
- package/components/related-content/example-related-content-social-media.njk +1 -1
- package/components/reply/_macro.njk +3 -1
- package/components/reply/_macro.spec.js +1 -1
- package/components/reply/reply.spec.js +1 -1
- package/components/section-navigation/_macro.njk +10 -10
- package/components/section-navigation/_macro.spec.js +15 -15
- package/components/section-navigation/_section-navigation.scss +3 -8
- package/components/section-navigation/example-section-navigation-single-vertical-with-title.njk +3 -3
- package/components/section-navigation/example-section-navigation-vertical.njk +14 -14
- package/components/section-navigation/example-section-navigation.njk +3 -3
- package/components/select/example-select-with-inline-label.njk +1 -1
- package/components/share-page/_macro.njk +7 -7
- package/components/share-page/_macro.spec.js +2 -2
- package/components/share-page/example-share-page.njk +1 -1
- package/components/status/_status.scss +1 -1
- package/components/summary/_macro.njk +33 -33
- package/components/summary/_macro.spec.js +34 -34
- package/components/summary/_summary.scss +2 -4
- package/components/summary/example-summary-card-grouped.njk +34 -34
- package/components/summary/example-summary-grouped-total.njk +7 -7
- package/components/summary/example-summary-grouped-with-errors.njk +9 -9
- package/components/summary/example-summary-grouped.njk +34 -34
- package/components/summary/example-summary-household.njk +7 -7
- package/components/summary/example-summary-hub-minimal.njk +8 -8
- package/components/summary/example-summary-hub.njk +16 -16
- package/components/summary/example-summary-multiple.njk +7 -7
- package/components/summary/example-summary-no-action.njk +5 -5
- package/components/summary/example-summary.njk +9 -9
- package/components/table/_table.scss +2 -3
- package/components/table-of-contents/_macro.njk +3 -3
- package/components/table-of-contents/_macro.spec.js +3 -3
- package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +1 -1
- package/components/tabs/_macro.njk +3 -3
- package/components/tabs/_macro.spec.js +3 -3
- package/components/tabs/_tabs.scss +3 -4
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/text-indent/_text-indent.scss +1 -1
- package/components/text-indent/example-text-indent.njk +1 -1
- package/components/timeline/_macro.njk +4 -4
- package/components/timeline/_macro.spec.js +3 -3
- package/components/timeline/_timeline.scss +4 -3
- package/components/timeline/example-timeline.njk +1 -1
- package/components/upload/_upload.scss +2 -2
- package/components/video/_macro.njk +4 -4
- package/components/video/_macro.spec.js +2 -2
- package/components/video/_video.scss +1 -1
- package/components/video/example-video.njk +2 -2
- package/components/video/video.spec.js +2 -2
- package/css/main.css +1 -1
- package/layout/_dsTemplate.njk +1 -1
- package/layout/_template.njk +31 -31
- package/package.json +3 -2
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_global.scss +2 -0
- package/scss/base/_typography.scss +0 -2
- package/scss/main.scss +0 -1
- package/scss/objects/_container.scss +1 -1
- package/scss/objects/_page.scss +2 -3
- package/scss/overrides/rtl.scss +1 -1
- package/scss/utilities/_grid.scss +103 -96
- package/scss/utilities/_margin.scss +11 -5
- package/scss/utilities/_padding.scss +12 -5
- package/scss/utilities/_typography.scss +2 -1
- package/scss/vars/_forms.scss +8 -10
- package/scss/vars/_grid.scss +4 -4
- package/scss/vars/_typography.scss +26 -19
- package/components/call-to-action/_call-to-action.scss +0 -8
- package/components/call-to-action/_macro.njk +0 -24
- package/components/call-to-action/_macro.spec.js +0 -48
- package/components/call-to-action/example-call-to-action-default.njk +0 -15
- package/components/metadata/_macro.njk +0 -14
package/README.md
CHANGED
|
@@ -44,6 +44,15 @@ yarn start
|
|
|
44
44
|
|
|
45
45
|
Once the server has started, navigate to <http://localhost:3030>
|
|
46
46
|
|
|
47
|
+
## Lighthouse Testing - local
|
|
48
|
+
|
|
49
|
+
This project uses [LHCI](https://www.npmjs.com/package/@lhci/cli).
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
yarn global add @lhci/cli
|
|
53
|
+
yarn test-lighthouse
|
|
54
|
+
```
|
|
55
|
+
|
|
47
56
|
## Testing - macros and scripts
|
|
48
57
|
|
|
49
58
|
This project uses [jest](https://jestjs.io/docs/cli) and supports its command line options.
|
|
@@ -112,7 +121,7 @@ It is sometimes useful to adjust the following settings when writing tests or di
|
|
|
112
121
|
|
|
113
122
|
## Testing - Visual regression tests
|
|
114
123
|
|
|
115
|
-
This project uses [Backstop JS](https://github.com/garris/BackstopJS) for visual regression testing. The tests run in Chrome headless using
|
|
124
|
+
This project uses [Backstop JS](https://github.com/garris/BackstopJS) for visual regression testing. The tests run in Chrome headless using Puppeteer inside docker and run in three viewports; 1920 (desktop), 768 (tablet) and 375 (mobile). Reference images are stored in Git LFS and any approved changes will automatically be stored in Git LFS when pushed to the repository.
|
|
116
125
|
|
|
117
126
|
The visual tests will run automatically on pull requests and the result will be available in the Github Action logs. If the tests fail, the process for viewing the failures and approving changes will need to be handled locally using the following workflow and commands.
|
|
118
127
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
{% macro onsAccessCode(params) %}
|
|
5
5
|
{% set groupSize = params.groupSize | default(4) %}
|
|
6
|
-
{% set extraSpaces = (params.
|
|
7
|
-
{% set
|
|
6
|
+
{% set extraSpaces = (params.maxLength | default(16) / groupSize) - 1 %}
|
|
7
|
+
{% set maxLength = params.maxLength | default(16) + extraSpaces %}
|
|
8
8
|
|
|
9
9
|
{% set content %}
|
|
10
10
|
{{
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"id": params.id,
|
|
13
13
|
"type": params.type,
|
|
14
14
|
"name": params.name,
|
|
15
|
-
"classes": "ons-access-code__input ons-js-access-code" + (" ons-u-mb-
|
|
15
|
+
"classes": "ons-access-code__input ons-js-access-code" + (" ons-u-mb-2xs" if params.postTextboxLinkText else ""),
|
|
16
16
|
"label": params.label,
|
|
17
|
+
"maxLength": maxLength,
|
|
17
18
|
"attributes": {
|
|
18
|
-
"maxlength": maxlength,
|
|
19
19
|
"data-group-size": groupSize,
|
|
20
20
|
"autocomplete": "off",
|
|
21
21
|
"autocapitalize": "characters"
|
|
@@ -5,7 +5,7 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
describe('FOR:
|
|
8
|
+
describe('FOR: Macro: Access-code', () => {
|
|
9
9
|
describe('GIVEN: Params: required', () => {
|
|
10
10
|
describe('WHEN: all required params are provided', () => {
|
|
11
11
|
const $ = cheerio.load(
|
|
@@ -24,7 +24,7 @@ describe('FOR: access-code', () => {
|
|
|
24
24
|
test('THEN: autocomplete is disabled on text input', () => {
|
|
25
25
|
expect($('input').attr('autocomplete')).toBe('off');
|
|
26
26
|
});
|
|
27
|
-
test('THEN: text input has
|
|
27
|
+
test('THEN: text input has autocapitalize attribute', () => {
|
|
28
28
|
expect($('input').attr('autocapitalize')).toBe('characters');
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -102,23 +102,23 @@ describe('FOR: access-code', () => {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
describe('GIVEN: Params:
|
|
105
|
+
describe('GIVEN: Params: maxLength & groupSize', () => {
|
|
106
106
|
describe('WHEN: params are at default state', () => {
|
|
107
107
|
const $ = cheerio.load(renderComponent('access-code'));
|
|
108
|
-
test('THEN: renders input with total
|
|
108
|
+
test('THEN: renders input with total maxLength of 19', () => {
|
|
109
109
|
expect($('input').attr('maxlength')).toBe('19');
|
|
110
110
|
});
|
|
111
111
|
test('THEN: renders input with groupSize of 4', () => {
|
|
112
112
|
expect($('input').attr('data-group-size')).toBe('4');
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
|
-
describe('WHEN:
|
|
115
|
+
describe('WHEN: maxLength param is provided', () => {
|
|
116
116
|
const $ = cheerio.load(
|
|
117
117
|
renderComponent('access-code', {
|
|
118
|
-
|
|
118
|
+
maxLength: 8,
|
|
119
119
|
}),
|
|
120
120
|
);
|
|
121
|
-
test('THEN: renders input with provided
|
|
121
|
+
test('THEN: renders input with provided maxLength', () => {
|
|
122
122
|
expect($('input').attr('maxlength')).toBe('9');
|
|
123
123
|
});
|
|
124
124
|
});
|
|
@@ -132,14 +132,14 @@ describe('FOR: access-code', () => {
|
|
|
132
132
|
expect($('input').attr('data-group-size')).toBe('2');
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
|
-
describe('WHEN:
|
|
135
|
+
describe('WHEN: maxLength and groupSize params are provided', () => {
|
|
136
136
|
const $ = cheerio.load(
|
|
137
137
|
renderComponent('access-code', {
|
|
138
|
-
|
|
138
|
+
maxLength: 6,
|
|
139
139
|
groupSize: 3,
|
|
140
140
|
}),
|
|
141
141
|
);
|
|
142
|
-
test('THEN: renders input with provided
|
|
142
|
+
test('THEN: renders input with provided maxLength accounting for provided groupSize', () => {
|
|
143
143
|
expect($('input').attr('maxlength')).toBe('7');
|
|
144
144
|
});
|
|
145
145
|
});
|
|
@@ -36,7 +36,7 @@ layout: ~
|
|
|
36
36
|
}}
|
|
37
37
|
{% endcall %}
|
|
38
38
|
|
|
39
|
-
<h1 class="ons-u-mt-
|
|
39
|
+
<h1 class="ons-u-mt-2xl">Start study</h1>
|
|
40
40
|
|
|
41
41
|
{{
|
|
42
42
|
onsAccessCode({
|
|
@@ -59,7 +59,7 @@ layout: ~
|
|
|
59
59
|
{{
|
|
60
60
|
onsButton({
|
|
61
61
|
"text": "Access study",
|
|
62
|
-
"classes": "ons-u-mb-
|
|
62
|
+
"classes": "ons-u-mb-2xl ons-u-mt-s"
|
|
63
63
|
})
|
|
64
64
|
}}
|
|
65
65
|
|
|
@@ -17,7 +17,7 @@ layout: ~
|
|
|
17
17
|
%}
|
|
18
18
|
|
|
19
19
|
{% block main %}
|
|
20
|
-
<h1 class="ons-u-mt-
|
|
20
|
+
<h1 class="ons-u-mt-2xl">Start study</h1>
|
|
21
21
|
|
|
22
22
|
{{
|
|
23
23
|
onsAccessCode({
|
|
@@ -36,7 +36,7 @@ layout: ~
|
|
|
36
36
|
{{
|
|
37
37
|
onsButton({
|
|
38
38
|
"text": "Access study",
|
|
39
|
-
"classes": "ons-u-mb-
|
|
39
|
+
"classes": "ons-u-mb-2xl ons-u-mt-s"
|
|
40
40
|
})
|
|
41
41
|
}}
|
|
42
42
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"headingAttributes": item.headingAttributes,
|
|
33
33
|
"contentAttributes": item.contentAttributes,
|
|
34
34
|
"title": item.title,
|
|
35
|
-
"
|
|
35
|
+
"headingLevel": item.headingLevel,
|
|
36
36
|
"content": item.content,
|
|
37
37
|
"group": params.id,
|
|
38
38
|
"saveState": params.saveState,
|
|
@@ -4,88 +4,106 @@ import * as cheerio from 'cheerio';
|
|
|
4
4
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const EXAMPLE_ACCORDION = {
|
|
23
|
-
...EXAMPLE_ACCORDION_WITH_TWO_ITEMS,
|
|
24
|
-
allButton: {
|
|
25
|
-
open: 'Open label',
|
|
26
|
-
close: 'Close label',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
describe('macro: accordion', () => {
|
|
31
|
-
it('passes jest-axe checks', async () => {
|
|
32
|
-
const $ = cheerio.load(renderComponent('accordion', EXAMPLE_ACCORDION));
|
|
33
|
-
|
|
34
|
-
const results = await axe($.html());
|
|
35
|
-
expect(results).toHaveNoViolations();
|
|
7
|
+
import { EXAMPLE_ACCORDION } from './_test_examples';
|
|
8
|
+
|
|
9
|
+
describe('FOR: Macro: Accordion', () => {
|
|
10
|
+
describe('GIVEN: Params: required', () => {
|
|
11
|
+
describe('WHEN: all required params are provided', () => {
|
|
12
|
+
const $ = cheerio.load(renderComponent('accordion', EXAMPLE_ACCORDION));
|
|
13
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
14
|
+
const results = await axe($.html());
|
|
15
|
+
expect(results).toHaveNoViolations();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
36
18
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
describe('GIVEN: Params: required and allButton', () => {
|
|
20
|
+
describe('WHEN: required and allButton params are provided', () => {
|
|
21
|
+
const $ = cheerio.load(
|
|
22
|
+
renderComponent('accordion', {
|
|
23
|
+
...EXAMPLE_ACCORDION,
|
|
24
|
+
allButton: {
|
|
25
|
+
open: 'Open label',
|
|
26
|
+
close: 'Close label',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
31
|
+
const results = await axe($.html());
|
|
32
|
+
expect(results).toHaveNoViolations();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
42
35
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect($('.ons-accordion').hasClass('extra-class')).toBe(true);
|
|
53
|
-
expect($('.ons-accordion').hasClass('another-extra-class')).toBe(true);
|
|
36
|
+
describe('GIVEN: Params: id', () => {
|
|
37
|
+
describe('WHEN: id is provided', () => {
|
|
38
|
+
const $ = cheerio.load(renderComponent('accordion', EXAMPLE_ACCORDION));
|
|
39
|
+
test('THEN: renders with provided id', () => {
|
|
40
|
+
expect($('.ons-accordion').attr('id')).toBe('accordion-identifier');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
54
43
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
describe('GIVEN: Params: classes', () => {
|
|
45
|
+
describe('WHEN: additional style classes are provided', () => {
|
|
46
|
+
const $ = cheerio.load(
|
|
47
|
+
renderComponent('accordion', {
|
|
48
|
+
...EXAMPLE_ACCORDION,
|
|
49
|
+
classes: 'extra-class another-extra-class',
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
test('THEN: renders with provided classes', () => {
|
|
53
|
+
expect($('.ons-accordion').hasClass('extra-class')).toBe(true);
|
|
54
|
+
expect($('.ons-accordion').hasClass('another-extra-class')).toBe(true);
|
|
55
|
+
});
|
|
62
56
|
});
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
});
|
|
58
|
+
describe('GIVEN: Params: itemsList: AccordionItem', () => {
|
|
59
|
+
describe('WHEN: title is provided', () => {
|
|
60
|
+
const $ = cheerio.load(renderComponent('accordion', EXAMPLE_ACCORDION));
|
|
61
|
+
test('THEN: renders title with provided text', () => {
|
|
62
|
+
const titleText = $('.ons-details__title').first().text().trim();
|
|
63
|
+
expect(titleText).toBe('Title for item 1');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('WHEN: titleTag is not provided', () => {
|
|
65
67
|
const $ = cheerio.load(
|
|
66
68
|
renderComponent('accordion', {
|
|
67
69
|
itemsList: [
|
|
68
70
|
{
|
|
69
71
|
title: 'Title for item 1',
|
|
70
|
-
titleTag: 'h5',
|
|
71
72
|
content: 'Content for item 1',
|
|
72
73
|
},
|
|
73
74
|
],
|
|
74
75
|
}),
|
|
75
76
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
test('THEN: item title renders with default heading tag', () => {
|
|
78
|
+
const titleTag = $('.ons-details__title')[0].tagName;
|
|
79
|
+
expect(titleTag).toBe('h2');
|
|
80
|
+
});
|
|
79
81
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
describe('WHEN: titleTag is provided', () => {
|
|
83
|
+
const $ = cheerio.load(
|
|
84
|
+
renderComponent('accordion', {
|
|
85
|
+
itemsList: [
|
|
86
|
+
{
|
|
87
|
+
title: 'Title for item 1',
|
|
88
|
+
headingLevel: 5,
|
|
89
|
+
content: 'Content for item 1',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
test('THEN: item title renders with provided heading tag', () => {
|
|
95
|
+
const titleTag = $('.ons-details__title')[0].tagName;
|
|
96
|
+
expect(titleTag).toBe('h5');
|
|
97
|
+
});
|
|
86
98
|
});
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
describe('WHEN: content is provided', () => {
|
|
100
|
+
const $ = cheerio.load(renderComponent('accordion', EXAMPLE_ACCORDION));
|
|
101
|
+
test('THEN: item content renders with provided text', () => {
|
|
102
|
+
const titleText = $('.ons-details__content').first().text().trim();
|
|
103
|
+
expect(titleText).toBe('Content for item 1');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('WHEN: attributes are provided', () => {
|
|
89
107
|
const $ = cheerio.load(
|
|
90
108
|
renderComponent('accordion', {
|
|
91
109
|
itemsList: [
|
|
@@ -99,12 +117,12 @@ describe('macro: accordion', () => {
|
|
|
99
117
|
],
|
|
100
118
|
}),
|
|
101
119
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
test('THEN: item renders with provided HTML attributes', () => {
|
|
121
|
+
expect($('.ons-details').attr('a')).toBe('123');
|
|
122
|
+
expect($('.ons-details').attr('b')).toBe('456');
|
|
123
|
+
});
|
|
105
124
|
});
|
|
106
|
-
|
|
107
|
-
it('has additionally provided `headingAttributes`', () => {
|
|
125
|
+
describe('WHEN: headingAttributes are provided', () => {
|
|
108
126
|
const $ = cheerio.load(
|
|
109
127
|
renderComponent('accordion', {
|
|
110
128
|
itemsList: [
|
|
@@ -118,12 +136,12 @@ describe('macro: accordion', () => {
|
|
|
118
136
|
],
|
|
119
137
|
}),
|
|
120
138
|
);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
test('THEN: item header renders with provided HTML attributes', () => {
|
|
140
|
+
expect($('.ons-details__heading').attr('a')).toBe('123');
|
|
141
|
+
expect($('.ons-details__heading').attr('b')).toBe('456');
|
|
142
|
+
});
|
|
124
143
|
});
|
|
125
|
-
|
|
126
|
-
it('has additionally provided `contentAttributes`', () => {
|
|
144
|
+
describe('WHEN: contentAttributes are provided', () => {
|
|
127
145
|
const $ = cheerio.load(
|
|
128
146
|
renderComponent('accordion', {
|
|
129
147
|
itemsList: [
|
|
@@ -138,31 +156,37 @@ describe('macro: accordion', () => {
|
|
|
138
156
|
],
|
|
139
157
|
}),
|
|
140
158
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
test('THEN: item content renders with provided HTML attributes', () => {
|
|
160
|
+
expect($('.ons-details__content').attr('a')).toBe('123');
|
|
161
|
+
expect($('.ons-details__content').attr('b')).toBe('456');
|
|
162
|
+
});
|
|
144
163
|
});
|
|
145
164
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
it('outputs a button with the expected class', () => {
|
|
165
|
+
describe('GIVEN: Params: allButton: AccordionButton', () => {
|
|
166
|
+
describe('WHEN: required open/close params are provided', () => {
|
|
149
167
|
const $ = cheerio.load(
|
|
150
168
|
renderComponent('accordion', {
|
|
151
|
-
...
|
|
169
|
+
...EXAMPLE_ACCORDION,
|
|
152
170
|
allButton: {
|
|
153
171
|
open: 'Open label',
|
|
154
172
|
close: 'Close label',
|
|
155
173
|
},
|
|
156
174
|
}),
|
|
157
175
|
);
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
test('THEN: renders button with expected class', () => {
|
|
177
|
+
expect($('button.ons-accordion__toggle-all').length).toBe(1);
|
|
178
|
+
});
|
|
179
|
+
test('THEN: renders button with provided open text', () => {
|
|
180
|
+
expect($('.ons-accordion__toggle-all-inner').text()).toBe('Open label');
|
|
181
|
+
});
|
|
182
|
+
test('THEN: renders button with provided close text', () => {
|
|
183
|
+
expect($('button.ons-accordion__toggle-all').attr('data-close-all')).toBe('Close label');
|
|
184
|
+
});
|
|
160
185
|
});
|
|
161
|
-
|
|
162
|
-
it('has additionally provided `attributes`', () => {
|
|
186
|
+
describe('WHEN: attributes are provided', () => {
|
|
163
187
|
const $ = cheerio.load(
|
|
164
188
|
renderComponent('accordion', {
|
|
165
|
-
...
|
|
189
|
+
...EXAMPLE_ACCORDION,
|
|
166
190
|
allButton: {
|
|
167
191
|
open: 'Open label',
|
|
168
192
|
close: 'Close label',
|
|
@@ -173,9 +197,56 @@ describe('macro: accordion', () => {
|
|
|
173
197
|
},
|
|
174
198
|
}),
|
|
175
199
|
);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
200
|
+
test('THEN: renders button with additional attributes provided', () => {
|
|
201
|
+
expect($('button.ons-accordion__toggle-all').attr('a')).toBe('123');
|
|
202
|
+
expect($('button.ons-accordion__toggle-all').attr('b')).toBe('456');
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
describe('GIVEN: Params: saveState', () => {
|
|
207
|
+
describe('WHEN: saveState param is not provided', () => {
|
|
208
|
+
const $ = cheerio.load(
|
|
209
|
+
renderComponent('accordion', {
|
|
210
|
+
...EXAMPLE_ACCORDION,
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
213
|
+
test('THEN: renders without saveState attribute', () => {
|
|
214
|
+
expect($('.ons-details--accordion').attr('saveState')).toBe(undefined);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
describe('WHEN: saveState param is set to true', () => {
|
|
218
|
+
const $ = cheerio.load(
|
|
219
|
+
renderComponent('accordion', {
|
|
220
|
+
...EXAMPLE_ACCORDION,
|
|
221
|
+
saveState: true,
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
test('THEN: renders with saveState attribute', () => {
|
|
225
|
+
expect($('.ons-details--accordion').attr('saveState'));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
describe('GIVEN: Params: open', () => {
|
|
230
|
+
describe('WHEN: open param is not provided', () => {
|
|
231
|
+
const $ = cheerio.load(
|
|
232
|
+
renderComponent('accordion', {
|
|
233
|
+
...EXAMPLE_ACCORDION,
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
test('THEN: renders with accordion items closed on page load', () => {
|
|
237
|
+
expect($('.ons-details--accordion').attr('open')).toBe(undefined);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
describe('WHEN: open param is set to true', () => {
|
|
241
|
+
const $ = cheerio.load(
|
|
242
|
+
renderComponent('accordion', {
|
|
243
|
+
...EXAMPLE_ACCORDION,
|
|
244
|
+
open: true,
|
|
245
|
+
}),
|
|
246
|
+
);
|
|
247
|
+
test('THEN: renders with accordion items open on page load', () => {
|
|
248
|
+
expect($('.ons-details--accordion').attr('open'));
|
|
249
|
+
});
|
|
179
250
|
});
|
|
180
251
|
});
|
|
181
252
|
});
|
|
@@ -132,9 +132,9 @@
|
|
|
132
132
|
"mutuallyExclusive": params.mutuallyExclusive
|
|
133
133
|
},
|
|
134
134
|
"externalInitialiser": true,
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
135
|
+
"apiDomain": params.apiDomain,
|
|
136
|
+
"apiDomainBearerToken": params.apiDomainBearerToken,
|
|
137
|
+
"apiManualQueryParams": params.apiManualQueryParams,
|
|
138
138
|
"allowMultiple": params.allowMultiple,
|
|
139
139
|
"mandatory": params.mandatory,
|
|
140
140
|
"instructions": params.instructions,
|
|
@@ -157,15 +157,15 @@
|
|
|
157
157
|
"errorTitle": params.errorTitle,
|
|
158
158
|
"errorMessageEnter": params.errorMessageEnter,
|
|
159
159
|
"errorMessageSelect": params.errorMessageSelect,
|
|
160
|
-
"
|
|
161
|
-
"
|
|
160
|
+
"errorMessageApi": params.errorMessageApi,
|
|
161
|
+
"errorMessageApiLinkText": params.errorMessageApiLinkText,
|
|
162
162
|
"options": params.options,
|
|
163
|
-
"
|
|
163
|
+
"manualLinkUrl": params.manualLinkUrl,
|
|
164
164
|
"manualLinkText": params.manualLinkText
|
|
165
165
|
})
|
|
166
166
|
}}
|
|
167
167
|
{% if params.manualLinkText %}
|
|
168
|
-
<a href="{{ params.
|
|
168
|
+
<a href="{{ params.manualLinkUrl }}" class="ons-js-address-manual-btn ons-u-mt-s ons-u-dib"
|
|
169
169
|
>{{ params.manualLinkText }}</a
|
|
170
170
|
>
|
|
171
171
|
{% endif %}
|
|
@@ -312,9 +312,9 @@ describe('macro: address-input', () => {
|
|
|
312
312
|
error: '[params.error]',
|
|
313
313
|
name: '[params.name]',
|
|
314
314
|
mutuallyExclusive: '[params.mutuallyExclusive]',
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
apiDomain: '[params.apiDomain]',
|
|
316
|
+
apiDomainBearerToken: '[params.apiDomainBearerToken]',
|
|
317
|
+
apiManualQueryParams: '[params.apiManualQueryParams]',
|
|
318
318
|
allowMultiple: '[params.allowMultiple]',
|
|
319
319
|
mandatory: '[params.mandatory]',
|
|
320
320
|
instructions: '[params.instructions]',
|
|
@@ -338,10 +338,10 @@ describe('macro: address-input', () => {
|
|
|
338
338
|
errorTitle: '[params.errorTitle]',
|
|
339
339
|
errorMessageEnter: '[params.errorMessageEnter]',
|
|
340
340
|
errorMessageSelect: '[params.errorMessageSelect]',
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
errorMessageApi: '[params.errorMessageApi]',
|
|
342
|
+
errorMessageApiLinkText: '[params.errorMessageApiLinkText]',
|
|
343
343
|
options: '[params.options]',
|
|
344
|
-
|
|
344
|
+
manualLinkUrl: '[params.manualLinkUrl]',
|
|
345
345
|
manualLinkText: '[params.manualLinkText]',
|
|
346
346
|
});
|
|
347
347
|
|
|
@@ -362,9 +362,9 @@ describe('macro: address-input', () => {
|
|
|
362
362
|
mutuallyExclusive: '[params.mutuallyExclusive]',
|
|
363
363
|
},
|
|
364
364
|
externalInitialiser: true,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
apiDomain: '[params.apiDomain]',
|
|
366
|
+
apiDomainBearerToken: '[params.apiDomainBearerToken]',
|
|
367
|
+
apiManualQueryParams: '[params.apiManualQueryParams]',
|
|
368
368
|
allowMultiple: '[params.allowMultiple]',
|
|
369
369
|
mandatory: '[params.mandatory]',
|
|
370
370
|
instructions: '[params.instructions]',
|
|
@@ -387,18 +387,19 @@ describe('macro: address-input', () => {
|
|
|
387
387
|
errorTitle: '[params.errorTitle]',
|
|
388
388
|
errorMessageEnter: '[params.errorMessageEnter]',
|
|
389
389
|
errorMessageSelect: '[params.errorMessageSelect]',
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
errorMessageApi: '[params.errorMessageApi]',
|
|
391
|
+
errorMessageApiLinkText: '[params.errorMessageApiLinkText]',
|
|
392
392
|
options: '[params.options]',
|
|
393
|
-
|
|
393
|
+
manualLinkUrl: '[params.manualLinkUrl]',
|
|
394
394
|
manualLinkText: '[params.manualLinkText]',
|
|
395
395
|
});
|
|
396
396
|
});
|
|
397
397
|
|
|
398
|
-
it('renders manualLinkText` when provided with a default value for `
|
|
398
|
+
it('renders manualLinkText` when provided with a default value for `manualLinkUrl`', () => {
|
|
399
399
|
const $ = cheerio.load(
|
|
400
400
|
renderComponent('address-input', {
|
|
401
401
|
...EXAMPLE_AUTOSUGGEST_ADDRESS_MINIMAL,
|
|
402
|
+
manualLinkUrl: '#0',
|
|
402
403
|
manualLinkText: 'Manually enter address',
|
|
403
404
|
}),
|
|
404
405
|
);
|
|
@@ -407,11 +408,11 @@ describe('macro: address-input', () => {
|
|
|
407
408
|
expect($('.ons-js-address-manual-btn').text().trim()).toBe('Manually enter address');
|
|
408
409
|
});
|
|
409
410
|
|
|
410
|
-
it('renders `manualLinkText` with `
|
|
411
|
+
it('renders `manualLinkText` with `manualLinkUrl` when provided', () => {
|
|
411
412
|
const $ = cheerio.load(
|
|
412
413
|
renderComponent('address-input', {
|
|
413
414
|
...EXAMPLE_AUTOSUGGEST_ADDRESS_MINIMAL,
|
|
414
|
-
|
|
415
|
+
manualLinkUrl: 'https://example.com/edit-address',
|
|
415
416
|
manualLinkText: 'Manually enter address',
|
|
416
417
|
}),
|
|
417
418
|
);
|
|
@@ -32,7 +32,7 @@ export default class AddressError {
|
|
|
32
32
|
const errorListElement = document.createElement('p');
|
|
33
33
|
const errorLinkElement = document.createElement('a');
|
|
34
34
|
|
|
35
|
-
errorElement.className = 'ons-panel ons-panel--error ons-u-mb-
|
|
35
|
+
errorElement.className = 'ons-panel ons-panel--error ons-u-mb-l ons-js-autosuggest-error-panel';
|
|
36
36
|
errorElementHeader.className = 'ons-panel__header';
|
|
37
37
|
errorElementTitle.className = 'ons-panel__title ons-u-fs-r--b';
|
|
38
38
|
errorBodyElement.className = 'ons-panel__body';
|