@ons/design-system 68.0.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
|
@@ -6,7 +6,7 @@ import axe from '../../tests/helpers/axe';
|
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
8
|
const EXAMPLE_MESSAGE_MINIMAL = {
|
|
9
|
-
|
|
9
|
+
variant: 'sent',
|
|
10
10
|
fromLabel: 'From',
|
|
11
11
|
fromValue: 'Example Sender',
|
|
12
12
|
sentLabel: 'Date sent',
|
|
@@ -35,13 +35,13 @@ describe('macro: message', () => {
|
|
|
35
35
|
it.each([
|
|
36
36
|
['sent', 'ons-message--sent'],
|
|
37
37
|
['received', 'ons-message--received'],
|
|
38
|
-
])('has appropriate class for provided `
|
|
38
|
+
])('has appropriate class for provided `variant` (%s -> %s)', (variant, expectedClass) => {
|
|
39
39
|
const $ = cheerio.load(
|
|
40
40
|
renderComponent(
|
|
41
41
|
'message',
|
|
42
42
|
{
|
|
43
43
|
...EXAMPLE_MESSAGE_MINIMAL,
|
|
44
|
-
|
|
44
|
+
variant,
|
|
45
45
|
},
|
|
46
46
|
['Message content...'],
|
|
47
47
|
),
|
|
@@ -59,21 +59,13 @@ describe('macro: message', () => {
|
|
|
59
59
|
it('has the provided `fromLabel`', () => {
|
|
60
60
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
61
61
|
|
|
62
|
-
expect(
|
|
63
|
-
$('.ons-message__sender .ons-message__term')
|
|
64
|
-
.text()
|
|
65
|
-
.trim(),
|
|
66
|
-
).toBe('From:');
|
|
62
|
+
expect($('.ons-message__sender .ons-message__term').text().trim()).toBe('From:');
|
|
67
63
|
});
|
|
68
64
|
|
|
69
65
|
it('has the provided `fromValue`', () => {
|
|
70
66
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
71
67
|
|
|
72
|
-
expect(
|
|
73
|
-
$('.ons-message__sender .ons-message__value')
|
|
74
|
-
.text()
|
|
75
|
-
.trim(),
|
|
76
|
-
).toBe('Example Sender');
|
|
68
|
+
expect($('.ons-message__sender .ons-message__value').text().trim()).toBe('Example Sender');
|
|
77
69
|
});
|
|
78
70
|
|
|
79
71
|
it('has the provided `fromId`', () => {
|
|
@@ -85,21 +77,13 @@ describe('macro: message', () => {
|
|
|
85
77
|
it('has the provided `sentLabel`', () => {
|
|
86
78
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
87
79
|
|
|
88
|
-
expect(
|
|
89
|
-
$('.ons-message__timestamp .ons-message__term')
|
|
90
|
-
.text()
|
|
91
|
-
.trim(),
|
|
92
|
-
).toBe('Date sent:');
|
|
80
|
+
expect($('.ons-message__timestamp .ons-message__term').text().trim()).toBe('Date sent:');
|
|
93
81
|
});
|
|
94
82
|
|
|
95
83
|
it('has the provided `sentValue`', () => {
|
|
96
84
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
97
85
|
|
|
98
|
-
expect(
|
|
99
|
-
$('.ons-message__timestamp .ons-message__value')
|
|
100
|
-
.text()
|
|
101
|
-
.trim(),
|
|
102
|
-
).toBe('Tue 4 Jul 2020 at 7:47');
|
|
86
|
+
expect($('.ons-message__timestamp .ons-message__value').text().trim()).toBe('Tue 4 Jul 2020 at 7:47');
|
|
103
87
|
});
|
|
104
88
|
|
|
105
89
|
it('has the provided `sentId`', () => {
|
|
@@ -117,20 +101,12 @@ describe('macro: message', () => {
|
|
|
117
101
|
it('has the provided `unreadLinkText`', () => {
|
|
118
102
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE, ['Message content...']));
|
|
119
103
|
|
|
120
|
-
expect(
|
|
121
|
-
$('.ons-message__unread-link')
|
|
122
|
-
.text()
|
|
123
|
-
.trim(),
|
|
124
|
-
).toBe('Unread message');
|
|
104
|
+
expect($('.ons-message__unread-link').text().trim()).toBe('Unread message');
|
|
125
105
|
});
|
|
126
106
|
|
|
127
107
|
it('has the message content', () => {
|
|
128
108
|
const $ = cheerio.load(renderComponent('message', EXAMPLE_MESSAGE_MINIMAL, ['Message content...']));
|
|
129
109
|
|
|
130
|
-
expect(
|
|
131
|
-
$('.ons-message__body')
|
|
132
|
-
.text()
|
|
133
|
-
.trim(),
|
|
134
|
-
).toBe('Message content...');
|
|
110
|
+
expect($('.ons-message__body').text().trim()).toBe('Message content...');
|
|
135
111
|
});
|
|
136
112
|
});
|
|
@@ -85,31 +85,19 @@ describe('macro: message-list', () => {
|
|
|
85
85
|
it('has `unreadText` for unread messages', () => {
|
|
86
86
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST));
|
|
87
87
|
|
|
88
|
-
expect(
|
|
89
|
-
$('#message1 .ons-message-item__unread')
|
|
90
|
-
.text()
|
|
91
|
-
.trim(),
|
|
92
|
-
).toBe('(New)');
|
|
88
|
+
expect($('#message1 .ons-message-item__unread').text().trim()).toBe('(New)');
|
|
93
89
|
});
|
|
94
90
|
|
|
95
91
|
it('has visually hidden label `fromLabel`', () => {
|
|
96
92
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
|
|
97
93
|
|
|
98
|
-
expect(
|
|
99
|
-
$('.ons-message-item__metadata-term--from:first')
|
|
100
|
-
.text()
|
|
101
|
-
.trim(),
|
|
102
|
-
).toBe('From:');
|
|
94
|
+
expect($('.ons-message-item__metadata-term--from:first').text().trim()).toBe('From:');
|
|
103
95
|
});
|
|
104
96
|
|
|
105
97
|
it('has visually hidden label `dateLabel`', () => {
|
|
106
98
|
const $ = cheerio.load(renderComponent('message-list', EXAMPLE_MESSAGE_LIST_MINIMAL));
|
|
107
99
|
|
|
108
|
-
expect(
|
|
109
|
-
$('.ons-message-item__metadata-term--date:first')
|
|
110
|
-
.text()
|
|
111
|
-
.trim(),
|
|
112
|
-
).toBe('Date:');
|
|
100
|
+
expect($('.ons-message-item__metadata-term--date:first').text().trim()).toBe('Date:');
|
|
113
101
|
});
|
|
114
102
|
|
|
115
103
|
it('has visually hidden label `hiddenReadLabel`', () => {
|
|
@@ -123,31 +111,11 @@ describe('macro: message-list', () => {
|
|
|
123
111
|
|
|
124
112
|
const $message2 = $('.ons-message-item:nth-child(2)');
|
|
125
113
|
|
|
126
|
-
expect(
|
|
127
|
-
$message2
|
|
128
|
-
.find('.ons-message-item__subject')
|
|
129
|
-
.text()
|
|
130
|
-
.trim(),
|
|
131
|
-
).toBe('Another example message subject');
|
|
114
|
+
expect($message2.find('.ons-message-item__subject').text().trim()).toBe('Another example message subject');
|
|
132
115
|
expect($message2.find('.ons-message-item__subject').attr('id')).toBe('message2');
|
|
133
|
-
expect(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.text()
|
|
137
|
-
.trim(),
|
|
138
|
-
).toBe('Example Sender 2');
|
|
139
|
-
expect(
|
|
140
|
-
$message2
|
|
141
|
-
.find('.ons-message-item__metadata-value--date')
|
|
142
|
-
.text()
|
|
143
|
-
.trim(),
|
|
144
|
-
).toBe('Mon 1 Oct 2019 at 9:52');
|
|
145
|
-
expect(
|
|
146
|
-
$message2
|
|
147
|
-
.find('.ons-message-item__body')
|
|
148
|
-
.text()
|
|
149
|
-
.trim(),
|
|
150
|
-
).toBe('Another example message.');
|
|
116
|
+
expect($message2.find('.ons-message-item__metadata-value--from').text().trim()).toBe('Example Sender 2');
|
|
117
|
+
expect($message2.find('.ons-message-item__metadata-value--date').text().trim()).toBe('Mon 1 Oct 2019 at 9:52');
|
|
118
|
+
expect($message2.find('.ons-message-item__body').text().trim()).toBe('Another example message.');
|
|
151
119
|
expect($message2.find('.ons-message-item__link a').attr('href')).toBe('https://example.com/message/2');
|
|
152
120
|
});
|
|
153
121
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
|
|
2
2
|
|
|
3
3
|
{% macro onsMetadata(params) %}
|
|
4
|
-
{{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}}
|
|
4
|
+
{{
|
|
5
|
+
onsDescriptionList({
|
|
6
|
+
"id": params.id,
|
|
7
|
+
"classes": params.classes,
|
|
8
|
+
"descriptionListLabel": params.metadataLabel,
|
|
9
|
+
"termCol": params.termCol,
|
|
10
|
+
"descriptionCol": params.descriptionCol,
|
|
11
|
+
"itemsList": params.itemsList
|
|
12
|
+
})
|
|
13
|
+
}}
|
|
14
14
|
{% endmacro %}
|
|
@@ -22,18 +22,14 @@ describe('macro: modal', () => {
|
|
|
22
22
|
it('has expected `title`', () => {
|
|
23
23
|
const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
|
|
24
24
|
|
|
25
|
-
const title = $('.ons-modal__title')
|
|
26
|
-
.html()
|
|
27
|
-
.trim();
|
|
25
|
+
const title = $('.ons-modal__title').html().trim();
|
|
28
26
|
expect(title).toBe('Modal title');
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
it('has expected `body`', () => {
|
|
32
30
|
const $ = cheerio.load(renderComponent('modal', EXAMPLE_MODAL_BASIC));
|
|
33
31
|
|
|
34
|
-
const title = $('.ons-modal__body')
|
|
35
|
-
.html()
|
|
36
|
-
.trim();
|
|
32
|
+
const title = $('.ons-modal__body').html().trim();
|
|
37
33
|
expect(title).toBe('Modal body text');
|
|
38
34
|
});
|
|
39
35
|
|
|
@@ -64,9 +60,7 @@ describe('macro: modal', () => {
|
|
|
64
60
|
it('calls with content', () => {
|
|
65
61
|
const $ = cheerio.load(renderComponent('modal', { EXAMPLE_MODAL_BASIC }, 'Example content...'));
|
|
66
62
|
|
|
67
|
-
const content = $('.ons-modal__body')
|
|
68
|
-
.text()
|
|
69
|
-
.trim();
|
|
63
|
+
const content = $('.ons-modal__body').text().trim();
|
|
70
64
|
expect(content).toBe('Example content...');
|
|
71
65
|
});
|
|
72
66
|
|
|
@@ -25,12 +25,12 @@ describe('script: modal', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('displays the modal', async () => {
|
|
28
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
28
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
29
29
|
expect(modalIsVisible).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('has the correct body class added', async () => {
|
|
33
|
-
const bodyClassAddition = await page.$eval('body', node => node.classList.contains('ons-modal-overlay'));
|
|
33
|
+
const bodyClassAddition = await page.$eval('body', (node) => node.classList.contains('ons-modal-overlay'));
|
|
34
34
|
expect(bodyClassAddition).toBe(true);
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -41,12 +41,12 @@ describe('script: modal', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it('hides the modal', async () => {
|
|
44
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
44
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
45
45
|
expect(modalIsVisible).toBe(false);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('has the body class removed', async () => {
|
|
49
|
-
const bodyClassAddition = await page.$eval('body', node => node.classList.contains('ons-modal-overlay'));
|
|
49
|
+
const bodyClassAddition = await page.$eval('body', (node) => node.classList.contains('ons-modal-overlay'));
|
|
50
50
|
expect(bodyClassAddition).toBe(false);
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -64,7 +64,7 @@ describe('script: modal', () => {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('closes the modal', async () => {
|
|
67
|
-
const modalIsVisible = await page.$eval('.ons-modal', node => node.classList.contains('ons-u-db'));
|
|
67
|
+
const modalIsVisible = await page.$eval('.ons-modal', (node) => node.classList.contains('ons-u-db'));
|
|
68
68
|
expect(modalIsVisible).toBe(false);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{% from "components/mutually-exclusive/_macro.njk" import onsMutuallyExclusive %}
|
|
2
|
+
{% from "components/fieldset/_macro.njk" import onsFieldset %}
|
|
3
|
+
|
|
4
|
+
{% macro onsMultipleInputFields(params) %}
|
|
5
|
+
{% set fields %}
|
|
6
|
+
{% if params.numberOfFields > 1 %}
|
|
7
|
+
<div class="ons-field-group">
|
|
8
|
+
{{ params.fields | safe }}
|
|
9
|
+
</div>
|
|
10
|
+
{% else %}
|
|
11
|
+
{{ params.fields | safe }}
|
|
12
|
+
{% endif %}
|
|
13
|
+
{% endset %}
|
|
14
|
+
|
|
15
|
+
{% if params.mutuallyExclusive %}
|
|
16
|
+
{% call onsMutuallyExclusive({
|
|
17
|
+
"id": params.id,
|
|
18
|
+
"legend": params.legendOrLabel,
|
|
19
|
+
"legendClasses": params.legendClasses,
|
|
20
|
+
"description": params.description,
|
|
21
|
+
"classes": params.classes,
|
|
22
|
+
"dontWrap": params.dontWrap if params.numberOfFields > 1 else true,
|
|
23
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
24
|
+
"exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
|
|
25
|
+
"or": params.mutuallyExclusive.or,
|
|
26
|
+
"deselectMessage": params.mutuallyExclusive.deselectMessage,
|
|
27
|
+
"deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
|
|
28
|
+
"deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective,
|
|
29
|
+
"error": params.error
|
|
30
|
+
}) %}
|
|
31
|
+
{{ fields | safe }}
|
|
32
|
+
{% endcall %}
|
|
33
|
+
{% elif params.numberOfFields > 1 %}
|
|
34
|
+
{% call onsFieldset({
|
|
35
|
+
"id": params.id,
|
|
36
|
+
"legend": params.legendOrLabel,
|
|
37
|
+
"legendClasses": params.legendClasses,
|
|
38
|
+
"description": params.description,
|
|
39
|
+
"classes": params.classes,
|
|
40
|
+
"dontWrap": params.dontWrap,
|
|
41
|
+
"legendIsQuestionTitle": params.legendIsQuestionTitle,
|
|
42
|
+
"error": params.error
|
|
43
|
+
}) %}
|
|
44
|
+
{{ fields | safe }}
|
|
45
|
+
{% endcall %}
|
|
46
|
+
{% else %}
|
|
47
|
+
{{ fields | safe }}
|
|
48
|
+
{% endif %}
|
|
49
|
+
{% endmacro %}
|
|
@@ -123,11 +123,7 @@ describe('macro: mutually-exclusive', () => {
|
|
|
123
123
|
it('renders visually hidden "Or" label', () => {
|
|
124
124
|
const $ = cheerio.load(renderComponent('mutually-exclusive', EXAMPLE_MUTUALLY_EXCLUSIVE, FAKE_FIELD));
|
|
125
125
|
|
|
126
|
-
expect(
|
|
127
|
-
$('.ons-checkboxes__label')
|
|
128
|
-
.text()
|
|
129
|
-
.trim(),
|
|
130
|
-
).toBe('Or');
|
|
126
|
+
expect($('.ons-checkboxes__label').text().trim()).toBe('Or');
|
|
131
127
|
});
|
|
132
128
|
|
|
133
129
|
it('renders a checkbox component with the expected parameters', () => {
|
|
@@ -159,11 +155,7 @@ describe('macro: mutually-exclusive', () => {
|
|
|
159
155
|
it('renders visually hidden "Or" label', () => {
|
|
160
156
|
const $ = cheerio.load(renderComponent('mutually-exclusive', EXAMPLE_MUTUALLY_EXCLUSIVE_RADIOS, FAKE_FIELD));
|
|
161
157
|
|
|
162
|
-
expect(
|
|
163
|
-
$('.ons-checkboxes__label')
|
|
164
|
-
.text()
|
|
165
|
-
.trim(),
|
|
166
|
-
).toBe('Or');
|
|
158
|
+
expect($('.ons-checkboxes__label').text().trim()).toBe('Or');
|
|
167
159
|
});
|
|
168
160
|
|
|
169
161
|
it('renders a radios component with the expected parameters', () => {
|
|
@@ -80,22 +80,22 @@ describe('script: mutually-exclusive', () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('then the mutually exclusive option is checked', async () => {
|
|
83
|
-
const isChecked = await page.$eval('#no-central-heating', node => node.checked);
|
|
83
|
+
const isChecked = await page.$eval('#no-central-heating', (node) => node.checked);
|
|
84
84
|
expect(isChecked).toBe(true);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
it('then the checkboxes are not checked', async () => {
|
|
88
|
-
expect(await page.$eval('#gas', node => node.checked)).toBe(false);
|
|
89
|
-
expect(await page.$eval('#electric', node => node.checked)).toBe(false);
|
|
90
|
-
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
91
|
-
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(false);
|
|
92
|
-
expect(await page.$eval('#other-fuel-textbox', node => node.value)).toBe('');
|
|
88
|
+
expect(await page.$eval('#gas', (node) => node.checked)).toBe(false);
|
|
89
|
+
expect(await page.$eval('#electric', (node) => node.checked)).toBe(false);
|
|
90
|
+
expect(await page.$eval('#solid-fuel', (node) => node.checked)).toBe(false);
|
|
91
|
+
expect(await page.$eval('#other-fuel', (node) => node.checked)).toBe(false);
|
|
92
|
+
expect(await page.$eval('#other-fuel-textbox', (node) => node.value)).toBe('');
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('then the aria-live message should reflect the removed non exclusive options', async () => {
|
|
96
96
|
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
97
97
|
|
|
98
|
-
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
98
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', (node) => node.textContent);
|
|
99
99
|
expect(alertText).toBe('Gas deselected. Electric deselected. Other deselected. Please specify deselected.');
|
|
100
100
|
});
|
|
101
101
|
});
|
|
@@ -114,20 +114,20 @@ describe('script: mutually-exclusive', () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it('then the expected checkboxes are checked', async () => {
|
|
117
|
-
expect(await page.$eval('#gas', node => node.checked)).toBe(true);
|
|
118
|
-
expect(await page.$eval('#electric', node => node.checked)).toBe(true);
|
|
119
|
-
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
120
|
-
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(true);
|
|
117
|
+
expect(await page.$eval('#gas', (node) => node.checked)).toBe(true);
|
|
118
|
+
expect(await page.$eval('#electric', (node) => node.checked)).toBe(true);
|
|
119
|
+
expect(await page.$eval('#solid-fuel', (node) => node.checked)).toBe(false);
|
|
120
|
+
expect(await page.$eval('#other-fuel', (node) => node.checked)).toBe(true);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
it('then the exclusive option should not be checked', async () => {
|
|
124
|
-
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(false);
|
|
124
|
+
expect(await page.$eval('#no-central-heating', (node) => node.checked)).toBe(false);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('then the aria-live message should reflect the removed exclusive option', async () => {
|
|
128
128
|
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
129
129
|
|
|
130
|
-
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
130
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', (node) => node.textContent);
|
|
131
131
|
expect(alertText).toBe('No central heating deselected.');
|
|
132
132
|
});
|
|
133
133
|
|
|
@@ -139,7 +139,7 @@ describe('script: mutually-exclusive', () => {
|
|
|
139
139
|
it('the aria-live message should not be updated', async () => {
|
|
140
140
|
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
141
141
|
|
|
142
|
-
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
142
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', (node) => node.textContent);
|
|
143
143
|
expect(alertText).toBe('No central heating deselected.');
|
|
144
144
|
});
|
|
145
145
|
});
|
|
@@ -155,20 +155,20 @@ describe('script: mutually-exclusive', () => {
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it('then the expected checkboxes are checked', async () => {
|
|
158
|
-
expect(await page.$eval('#gas', node => node.checked)).toBe(true);
|
|
159
|
-
expect(await page.$eval('#electric', node => node.checked)).toBe(true);
|
|
160
|
-
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
161
|
-
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(true);
|
|
158
|
+
expect(await page.$eval('#gas', (node) => node.checked)).toBe(true);
|
|
159
|
+
expect(await page.$eval('#electric', (node) => node.checked)).toBe(true);
|
|
160
|
+
expect(await page.$eval('#solid-fuel', (node) => node.checked)).toBe(false);
|
|
161
|
+
expect(await page.$eval('#other-fuel', (node) => node.checked)).toBe(true);
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
it('then the exclusive option should not be checked', async () => {
|
|
165
|
-
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(false);
|
|
165
|
+
expect(await page.$eval('#no-central-heating', (node) => node.checked)).toBe(false);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it('then the aria-live message should say nothing', async () => {
|
|
169
169
|
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
170
170
|
|
|
171
|
-
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
171
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', (node) => node.textContent);
|
|
172
172
|
expect(alertText).toBe('');
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -181,20 +181,20 @@ describe('script: mutually-exclusive', () => {
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
it('then the expected checkboxes are not checked', async () => {
|
|
184
|
-
expect(await page.$eval('#gas', node => node.checked)).toBe(false);
|
|
185
|
-
expect(await page.$eval('#electric', node => node.checked)).toBe(false);
|
|
186
|
-
expect(await page.$eval('#solid-fuel', node => node.checked)).toBe(false);
|
|
187
|
-
expect(await page.$eval('#other-fuel', node => node.checked)).toBe(false);
|
|
184
|
+
expect(await page.$eval('#gas', (node) => node.checked)).toBe(false);
|
|
185
|
+
expect(await page.$eval('#electric', (node) => node.checked)).toBe(false);
|
|
186
|
+
expect(await page.$eval('#solid-fuel', (node) => node.checked)).toBe(false);
|
|
187
|
+
expect(await page.$eval('#other-fuel', (node) => node.checked)).toBe(false);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
it('then the exclusive option should be checked', async () => {
|
|
191
|
-
expect(await page.$eval('#no-central-heating', node => node.checked)).toBe(true);
|
|
191
|
+
expect(await page.$eval('#no-central-heating', (node) => node.checked)).toBe(true);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
it('then the aria-live message should say nothing', async () => {
|
|
195
195
|
await page.waitForTimeout(SCREEN_READER_TIMEOUT_DELAY);
|
|
196
196
|
|
|
197
|
-
const alertText = await page.$eval('.ons-js-exclusive-alert', node => node.textContent);
|
|
197
|
+
const alertText = await page.$eval('.ons-js-exclusive-alert', (node) => node.textContent);
|
|
198
198
|
expect(alertText).toBe('');
|
|
199
199
|
});
|
|
200
200
|
});
|