@ons/design-system 50.0.0 → 52.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -15
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +162 -0
- package/components/access-code/uac.spec.js +26 -0
- package/components/accordion/_macro.spec.js +224 -0
- package/components/accordion/accordion.spec.js +134 -0
- package/components/address-input/_macro.njk +1 -1
- package/components/address-input/_macro.spec.js +465 -0
- package/components/address-input/autosuggest.address.js +5 -4
- package/components/address-input/autosuggest.address.setter.js +9 -3
- package/components/address-input/autosuggest.address.spec.js +733 -0
- package/components/address-output/_macro.njk +6 -6
- package/components/address-output/_macro.spec.js +122 -0
- package/components/autosuggest/_macro.njk +1 -1
- package/components/autosuggest/_macro.spec.js +229 -0
- package/components/autosuggest/autosuggest.helpers.js +2 -3
- package/components/autosuggest/autosuggest.helpers.spec.js +85 -0
- package/components/autosuggest/autosuggest.js +4 -2
- package/components/autosuggest/autosuggest.spec.js +625 -0
- package/components/autosuggest/autosuggest.ui.js +6 -2
- package/components/breadcrumbs/_macro.spec.js +129 -0
- package/components/button/_macro.njk +5 -5
- package/components/button/_macro.spec.js +446 -0
- package/components/button/button.spec.js +290 -0
- package/components/call-to-action/_macro.njk +3 -1
- package/components/call-to-action/_macro.spec.js +52 -0
- package/components/card/_macro.njk +26 -19
- package/components/card/_macro.spec.js +261 -0
- package/components/char-check-limit/_macro.spec.js +73 -0
- package/components/char-check-limit/character-check.spec.js +196 -0
- package/components/char-check-limit/character-limit.js +1 -1
- package/components/checkboxes/_checkbox-macro.spec.js +419 -0
- package/components/checkboxes/_macro.njk +1 -3
- package/components/checkboxes/_macro.spec.js +306 -0
- package/components/checkboxes/checkbox-with-autoselect.js +2 -1
- package/components/checkboxes/checkboxes.spec.js +208 -0
- package/components/code-highlight/_macro.spec.js +56 -0
- package/components/code-highlight/code-highlight.spec.js +18 -0
- package/components/collapsible/_macro.spec.js +204 -0
- package/components/collapsible/collapsible.js +2 -1
- package/components/collapsible/collapsible.spec.js +236 -0
- package/components/content-pagination/_macro.spec.js +199 -0
- package/components/cookies-banner/_macro.njk +1 -1
- package/components/cookies-banner/_macro.spec.js +171 -0
- package/components/cookies-banner/cookies-banner.spec.js +90 -0
- package/components/date-input/_macro.njk +6 -3
- package/components/date-input/_macro.spec.js +286 -0
- package/components/document-list/_macro.njk +3 -5
- package/components/document-list/_macro.spec.js +491 -0
- package/components/download-resources/download-resources.spec.js +540 -0
- package/components/duration/_macro.njk +7 -6
- package/components/duration/_macro.spec.js +251 -0
- package/components/error/_macro.spec.js +97 -0
- package/components/external-link/_macro.spec.js +60 -0
- package/components/feedback/_macro.njk +5 -3
- package/components/feedback/_macro.spec.js +122 -0
- package/components/field/_macro.njk +2 -2
- package/components/field/_macro.spec.js +97 -0
- package/components/fieldset/_macro.njk +3 -3
- package/components/fieldset/_macro.spec.js +173 -0
- package/components/footer/_macro.njk +12 -49
- package/components/footer/_macro.spec.js +549 -0
- package/components/header/_macro.njk +3 -3
- package/components/header/_macro.spec.js +562 -0
- package/components/hero/_hero.scss +0 -3
- package/components/hero/_macro.njk +4 -4
- package/components/hero/_macro.spec.js +224 -0
- package/components/icons/_macro.njk +15 -15
- package/components/icons/_macro.spec.js +140 -0
- package/components/images/_macro.njk +1 -1
- package/components/images/_macro.spec.js +121 -0
- package/components/input/_input-type.scss +12 -5
- package/components/input/_macro.njk +4 -5
- package/components/input/_macro.spec.js +658 -0
- package/components/label/_macro.spec.js +189 -0
- package/components/language-selector/_macro.spec.js +129 -0
- package/components/lists/_list.scss +4 -0
- package/components/lists/_macro.njk +4 -7
- package/components/lists/_macro.spec.js +618 -0
- package/components/message/_macro.spec.js +137 -0
- package/components/message-list/_macro.njk +7 -7
- package/components/message-list/_macro.spec.js +159 -0
- package/components/metadata/_macro.spec.js +167 -0
- package/components/modal/_macro.njk +6 -6
- package/components/modal/_macro.spec.js +87 -0
- package/components/modal/modal.js +0 -16
- package/components/modal/modal.spec.js +59 -0
- package/components/mutually-exclusive/_macro.njk +2 -2
- package/components/mutually-exclusive/_macro.spec.js +184 -0
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +203 -0
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +142 -0
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +141 -0
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +117 -0
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +213 -0
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +125 -0
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +131 -0
- package/components/navigation/_macro.njk +6 -6
- package/components/navigation/_macro.spec.js +327 -0
- package/components/navigation/navigation.dom.js +1 -1
- package/components/navigation/navigation.spec.js +232 -0
- package/components/pagination/_macro.njk +1 -1
- package/components/pagination/_macro.spec.js +411 -0
- package/components/panel/_macro.njk +6 -6
- package/components/panel/_macro.spec.js +423 -0
- package/components/password/_macro.spec.js +137 -0
- package/components/password/password.spec.js +40 -0
- package/components/phase-banner/_macro.spec.js +73 -0
- package/components/promotional-banner/_macro.spec.js +97 -0
- package/components/question/_macro.njk +16 -22
- package/components/question/_macro.spec.js +309 -0
- package/components/quote/_macro.spec.js +81 -0
- package/components/radios/_macro.njk +3 -6
- package/components/radios/_macro.spec.js +575 -0
- package/components/radios/radios.spec.js +180 -0
- package/components/related-content/_macro.njk +1 -0
- package/components/related-content/_macro.spec.js +142 -0
- package/components/relationships/_macro.spec.js +108 -0
- package/components/relationships/relationships.spec.js +84 -0
- package/components/reply/_macro.njk +2 -2
- package/components/reply/_macro.spec.js +69 -0
- package/components/reply/reply.spec.js +78 -0
- package/components/search/_macro.njk +14 -12
- package/components/search/_macro.spec.js +44 -0
- package/components/search/_search.scss +7 -7
- package/components/section-navigation/_macro.njk +7 -2
- package/components/section-navigation/_macro.spec.js +206 -0
- package/components/select/_macro.njk +3 -3
- package/components/select/_macro.spec.js +203 -0
- package/components/select/select.spec.js +56 -0
- package/components/share-page/_macro.njk +2 -2
- package/components/share-page/_macro.spec.js +110 -0
- package/components/skip-to-content/_macro.spec.js +57 -0
- package/components/skip-to-content/skip-to-content.spec.js +44 -0
- package/components/status/_macro.spec.js +77 -0
- package/components/summary/_macro.njk +5 -5
- package/components/summary/_macro.spec.js +472 -0
- package/components/table/_macro.njk +2 -2
- package/components/table/_macro.spec.js +557 -0
- package/components/table/table.spec.js +155 -0
- package/components/table-of-contents/_macro.njk +35 -35
- package/components/table-of-contents/_macro.spec.js +178 -0
- package/components/table-of-contents/toc.js +29 -25
- package/components/table-of-contents/toc.spec.js +61 -0
- package/components/tabs/_macro.njk +1 -1
- package/components/tabs/_macro.spec.js +79 -0
- package/components/tabs/tabs.spec.js +162 -0
- package/components/text-indent/_macro.spec.js +52 -0
- package/components/textarea/_macro.njk +5 -3
- package/components/textarea/_macro.spec.js +300 -0
- package/components/textarea/textarea.spec.js +98 -0
- package/components/timeline/_macro.njk +3 -3
- package/components/timeline/_macro.spec.js +81 -0
- package/components/timeout-modal/_macro.spec.js +68 -0
- package/components/timeout-modal/timeout-modal.spec.js +226 -0
- package/components/timeout-panel/_macro.njk +0 -1
- package/components/timeout-panel/_macro.spec.js +54 -0
- package/components/timeout-panel/timeout-panel.dom.js +1 -2
- package/components/timeout-panel/timeout-panel.spec.js +161 -0
- package/components/upload/_macro.spec.js +75 -0
- package/components/video/_macro.spec.js +34 -0
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/cookies-settings.spec.js +154 -0
- package/package.json +10 -23
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +2 -2
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
|
|
5
|
+
import axe from '../../tests/helpers/axe';
|
|
6
|
+
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
7
|
+
|
|
8
|
+
const EXAMPLE_SUMMARY_ROWS = {
|
|
9
|
+
rows: [
|
|
10
|
+
{
|
|
11
|
+
// Contains - row with icon, attributes and rowTitleAttributes, other value, no action
|
|
12
|
+
id: 'row-id-1',
|
|
13
|
+
rowTitle: 'row title 1',
|
|
14
|
+
rowItems: [
|
|
15
|
+
{
|
|
16
|
+
rowTitleAttributes: {
|
|
17
|
+
a: 123,
|
|
18
|
+
b: 456,
|
|
19
|
+
},
|
|
20
|
+
attributes: {
|
|
21
|
+
a: 'aaa',
|
|
22
|
+
b: 'bbb',
|
|
23
|
+
},
|
|
24
|
+
iconType: 'check',
|
|
25
|
+
id: 'item-id-1',
|
|
26
|
+
valueList: [
|
|
27
|
+
{
|
|
28
|
+
text: 'row value 1',
|
|
29
|
+
other: 'other value',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// Contains - row with error and multiple actions
|
|
37
|
+
id: 'row-id-2',
|
|
38
|
+
rowTitle: 'row title 2',
|
|
39
|
+
error: true,
|
|
40
|
+
errorMessage: 'there are errors',
|
|
41
|
+
rowItems: [
|
|
42
|
+
{
|
|
43
|
+
id: 'item-id-2',
|
|
44
|
+
valueList: [
|
|
45
|
+
{
|
|
46
|
+
text: 'row value 2',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
actions: [
|
|
50
|
+
{
|
|
51
|
+
text: 'Action 1',
|
|
52
|
+
ariaLabel: 'action aria label 1',
|
|
53
|
+
attributes: {
|
|
54
|
+
a: 'abc',
|
|
55
|
+
b: 'def',
|
|
56
|
+
},
|
|
57
|
+
url: '#1',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
text: 'Action 2',
|
|
61
|
+
ariaLabel: 'action aria label 2',
|
|
62
|
+
url: '#2',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
// Contains - row with multiple rows and multiple values
|
|
70
|
+
id: 'row-id-3',
|
|
71
|
+
rowTitle: 'row title 3',
|
|
72
|
+
rowItems: [
|
|
73
|
+
{
|
|
74
|
+
id: 'item-id-3',
|
|
75
|
+
valueList: [
|
|
76
|
+
{
|
|
77
|
+
text: 'row value 3',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
text: 'row value 3b',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'item-id-4',
|
|
86
|
+
valueList: [
|
|
87
|
+
{
|
|
88
|
+
text: 'row value 4',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
// Contains - row with total
|
|
96
|
+
id: 'row-id-4',
|
|
97
|
+
rowTitle: 'row title 4',
|
|
98
|
+
total: true,
|
|
99
|
+
rowItems: [
|
|
100
|
+
{
|
|
101
|
+
id: 'item-id-5',
|
|
102
|
+
valueList: [
|
|
103
|
+
{
|
|
104
|
+
text: '£234,000.00',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const EXAMPLE_SUMMARY_GROUPS = {
|
|
114
|
+
groups: [
|
|
115
|
+
{
|
|
116
|
+
id: 'group-id-1',
|
|
117
|
+
groupTitle: 'group title',
|
|
118
|
+
headers: ['Header 1', 'Header 2', 'Header 3'],
|
|
119
|
+
...EXAMPLE_SUMMARY_ROWS,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const EXAMPLE_SUMMARY_GROUPS_NO_ROWS = {
|
|
125
|
+
groups: [
|
|
126
|
+
{
|
|
127
|
+
placeholderText: 'Placeholder text',
|
|
128
|
+
summaryLink: {
|
|
129
|
+
text: 'Summary link',
|
|
130
|
+
url: '#0',
|
|
131
|
+
attributes: {
|
|
132
|
+
a: 'xyz',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const EXAMPLE_SUMMARY_BASIC = {
|
|
140
|
+
summaries: [
|
|
141
|
+
{
|
|
142
|
+
...EXAMPLE_SUMMARY_GROUPS,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const EXAMPLE_SUMMARY_WITH_TITLE = {
|
|
148
|
+
summaries: [
|
|
149
|
+
{
|
|
150
|
+
summaryTitle: 'summary title',
|
|
151
|
+
...EXAMPLE_SUMMARY_GROUPS,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const EXAMPLE_SUMMARY_WITH_NO_ROWS = {
|
|
157
|
+
summaries: [
|
|
158
|
+
{
|
|
159
|
+
summaryTitle: 'summary title',
|
|
160
|
+
...EXAMPLE_SUMMARY_GROUPS_NO_ROWS,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
describe('macro: summary', () => {
|
|
166
|
+
describe('mode: general', () => {
|
|
167
|
+
it('passes jest-axe checks', async () => {
|
|
168
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
169
|
+
|
|
170
|
+
const results = await axe($.html());
|
|
171
|
+
expect(results).toHaveNoViolations();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('has custom classes applied', () => {
|
|
175
|
+
const $ = cheerio.load(
|
|
176
|
+
renderComponent('summary', {
|
|
177
|
+
...EXAMPLE_SUMMARY_BASIC,
|
|
178
|
+
classes: 'ons-custom-class',
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
expect($('.ons-summary').hasClass('ons-custom-class')).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe('part: group', () => {
|
|
186
|
+
it('has the correct group `id`', () => {
|
|
187
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
188
|
+
|
|
189
|
+
expect($('#group-id-1').length).toBe(1);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('has the correct `groupTitle` tag', () => {
|
|
193
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
194
|
+
|
|
195
|
+
expect($('.ons-summary__group-title')[0].tagName).toBe('h2');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('has the `groupTitle` text', () => {
|
|
199
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
200
|
+
|
|
201
|
+
expect($('.ons-summary__group-title').text()).toBe('group title');
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('part: row', () => {
|
|
206
|
+
it('has the `headers` values displayed in th elements', () => {
|
|
207
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
208
|
+
|
|
209
|
+
expect($('.ons-summary__items thead tr th:nth-child(1)').text()).toBe('Header 1');
|
|
210
|
+
expect($('.ons-summary__items thead tr th:nth-child(2)').text()).toBe('Header 2');
|
|
211
|
+
expect($('.ons-summary__items thead tr th:nth-child(3)').text()).toBe('Header 3');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('has the correct row class when `error` is `true`', () => {
|
|
215
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
216
|
+
|
|
217
|
+
expect($('.ons-summary__items tbody:nth-of-type(2)').hasClass('ons-summary__item--error')).toBe(true);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('has the correct row class when `total` is `true`', () => {
|
|
221
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
222
|
+
|
|
223
|
+
expect($('.ons-summary__items tbody:nth-of-type(4)').hasClass('ons-summary__item--total')).toBe(true);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('displays the `rowTitle` text', () => {
|
|
227
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
228
|
+
|
|
229
|
+
expect($('.ons-summary__items tbody:nth-of-type(3) .ons-summary__row-title').text()).toBe('row title 3');
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('overrides the `rowTitle` with the `errorMessage` if provided', () => {
|
|
233
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_TITLE));
|
|
234
|
+
|
|
235
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__row-title').text()).toBe('there are errors');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('has the correct row `id` for each row', () => {
|
|
239
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
240
|
+
|
|
241
|
+
expect($('#row-id-1').length).toBe(1);
|
|
242
|
+
expect($('#row-id-2').length).toBe(1);
|
|
243
|
+
expect($('#row-id-3').length).toBe(1);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('has the correct class for each row when there is a `valueList`', () => {
|
|
247
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
248
|
+
|
|
249
|
+
expect($('.ons-summary__row--has-values').length).toBe(5);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('has custom `rowTitleAttributes`', () => {
|
|
253
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
254
|
+
|
|
255
|
+
expect($('.ons-summary__item-title').attr('a')).toBe('123');
|
|
256
|
+
expect($('.ons-summary__item-title').attr('b')).toBe('456');
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
describe('part: item title', () => {
|
|
261
|
+
it('displays the `rowTitle` text', () => {
|
|
262
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
263
|
+
|
|
264
|
+
expect(
|
|
265
|
+
$('.ons-summary__items tbody:nth-of-type(1) .ons-summary__item--text')
|
|
266
|
+
.text()
|
|
267
|
+
.trim(),
|
|
268
|
+
).toBe('row title 1');
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('has a custom icon `iconType`', () => {
|
|
272
|
+
const faker = templateFaker();
|
|
273
|
+
const iconsSpy = faker.spy('icons');
|
|
274
|
+
|
|
275
|
+
faker.renderComponent('summary', EXAMPLE_SUMMARY_BASIC);
|
|
276
|
+
|
|
277
|
+
expect(iconsSpy.occurrences[0].iconType).toBe('check');
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('has the correct icon class when `iconType` is `check`', () => {
|
|
281
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
282
|
+
|
|
283
|
+
expect($('.ons-summary__item-title-icon').hasClass('ons-summary__item-title-icon--check')).toBe(true);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('has the correct item text class when `iconType` is provided', () => {
|
|
287
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
288
|
+
|
|
289
|
+
expect($('.ons-summary__item--text').hasClass('ons-summary__item-title--text')).toBe(true);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('has a colspan attribute on the values td if there are no `actions`', () => {
|
|
293
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
294
|
+
|
|
295
|
+
expect($('.ons-summary__items tbody:nth-of-type(1) .ons-summary__values').attr('colspan')).toBe('2');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('has custom `attributes`', () => {
|
|
299
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
300
|
+
|
|
301
|
+
expect($('.ons-summary__values').attr('a')).toBe('aaa');
|
|
302
|
+
expect($('.ons-summary__values').attr('b')).toBe('bbb');
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('part: item value', () => {
|
|
307
|
+
it('displays the `valueList` text', () => {
|
|
308
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
309
|
+
|
|
310
|
+
expect(
|
|
311
|
+
$('.ons-summary__items tbody:nth-of-type(1) tr .ons-summary__values .ons-summary__text')
|
|
312
|
+
.text()
|
|
313
|
+
.trim(),
|
|
314
|
+
).toBe('row value 1');
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('displays the `other` text', () => {
|
|
318
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
319
|
+
|
|
320
|
+
expect(
|
|
321
|
+
$('.ons-summary__items tbody:nth-of-type(1) tr .ons-summary__values ul li')
|
|
322
|
+
.text()
|
|
323
|
+
.trim(),
|
|
324
|
+
).toBe('other value');
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('wraps the `valueList` in a ul if multiple values provided', () => {
|
|
328
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
329
|
+
|
|
330
|
+
expect($('.ons-summary__items tbody:nth-of-type(3) .ons-summary__values ul').length).toBe(1);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe('part: item action', () => {
|
|
335
|
+
it('has a spacer element if multiple actions are provided', () => {
|
|
336
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
337
|
+
|
|
338
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__spacer').length).toBe(1);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('has the correct `url` for each action provided', () => {
|
|
342
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
343
|
+
|
|
344
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:first-child').attr('href')).toBe(
|
|
345
|
+
'#1',
|
|
346
|
+
);
|
|
347
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:last-child').attr('href')).toBe('#2');
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('has the action `text` for each action provided', () => {
|
|
351
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
352
|
+
|
|
353
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:first-child').text()).toBe(
|
|
354
|
+
'Action 1',
|
|
355
|
+
);
|
|
356
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:last-child').text()).toBe('Action 2');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('has the `aria-label` provided', () => {
|
|
360
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
361
|
+
|
|
362
|
+
expect(
|
|
363
|
+
$('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:first-child').attr('aria-label'),
|
|
364
|
+
).toBe('action aria label 1');
|
|
365
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:last-child').attr('aria-label')).toBe(
|
|
366
|
+
'action aria label 2',
|
|
367
|
+
);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('has custom `attributes`', () => {
|
|
371
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
|
|
372
|
+
|
|
373
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:first-child').attr('a')).toBe('abc');
|
|
374
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__actions .ons-summary__button:first-child').attr('b')).toBe('def');
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe('mode: with title', () => {
|
|
380
|
+
it('passes jest-axe checks', async () => {
|
|
381
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_TITLE));
|
|
382
|
+
|
|
383
|
+
const results = await axe($.html());
|
|
384
|
+
expect(results).toHaveNoViolations();
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('displays the `summaryTitle`', () => {
|
|
388
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_TITLE));
|
|
389
|
+
|
|
390
|
+
expect($('.ons-summary__title').text()).toBe('summary title');
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
describe('mode: hub', () => {
|
|
395
|
+
it('passes jest-axe checks', async () => {
|
|
396
|
+
const $ = cheerio.load(
|
|
397
|
+
renderComponent('summary', {
|
|
398
|
+
...EXAMPLE_SUMMARY_BASIC,
|
|
399
|
+
hub: true,
|
|
400
|
+
}),
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
const results = await axe($.html());
|
|
404
|
+
expect(results).toHaveNoViolations();
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it('has the correct class applied', () => {
|
|
408
|
+
const $ = cheerio.load(
|
|
409
|
+
renderComponent('summary', {
|
|
410
|
+
...EXAMPLE_SUMMARY_BASIC,
|
|
411
|
+
hub: true,
|
|
412
|
+
}),
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
expect($('.ons-summary').hasClass('ons-summary--hub')).toBe(true);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it('has the value rendered after the `rowTitle` that shows on mobile', () => {
|
|
419
|
+
const $ = cheerio.load(
|
|
420
|
+
renderComponent('summary', {
|
|
421
|
+
...EXAMPLE_SUMMARY_BASIC,
|
|
422
|
+
hub: true,
|
|
423
|
+
}),
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
expect($('.ons-summary__items tbody:nth-of-type(2) .ons-summary__item-title span').text()).toBe(' — row value 2');
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
describe('mode: no rows', () => {
|
|
431
|
+
it('passes jest-axe checks', async () => {
|
|
432
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
433
|
+
|
|
434
|
+
const results = await axe($.html());
|
|
435
|
+
expect(results).toHaveNoViolations();
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('has the `placeholderText` provided', () => {
|
|
439
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
440
|
+
|
|
441
|
+
expect($('.ons-summary__group .ons-summary__placeholder').text()).toBe('Placeholder text');
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it('has the correct class added to the `summaryLink` when `placeholderText` is provided', () => {
|
|
445
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
446
|
+
|
|
447
|
+
expect($('.ons-summary__group .ons-summary__link').hasClass('ons-u-pt-s')).toBe(true);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('has custom `attributes` on the `summaryLink`', () => {
|
|
451
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
452
|
+
|
|
453
|
+
expect($('.ons-summary__group .ons-summary__link a').attr('a')).toBe('xyz');
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
it('has the correct link `text`', () => {
|
|
457
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
458
|
+
|
|
459
|
+
expect(
|
|
460
|
+
$('.ons-summary__group .ons-summary__link a')
|
|
461
|
+
.text()
|
|
462
|
+
.trim(),
|
|
463
|
+
).toBe('Summary link');
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it('has the correct link `url`', () => {
|
|
467
|
+
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
|
|
468
|
+
|
|
469
|
+
expect($('.ons-summary__group .ons-summary__link a').attr('href')).toBe('#0');
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
{% if 'scrollable' in variants %}
|
|
8
8
|
<div class="ons-table-scrollable ons-table-scrollable--on">
|
|
9
|
-
<div class="ons-table-scrollable__content" tabindex="0" role="region" aria-label="{{ params.caption }}. {{ params.ariaLabel | default("Scrollable table") }}
|
|
9
|
+
<div class="ons-table-scrollable__content" tabindex="0" role="region" aria-label="{{ params.caption }}. {{ params.ariaLabel | default("Scrollable table") }}">
|
|
10
10
|
{% endif %}
|
|
11
11
|
<table {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %} class="ons-table{% if params.tableClasses is defined and params.tableClasses %} {{ params.tableClasses }}{% endif %}{% if variants is defined and variants %}{% if variants is not string %}{% for variant in variants %} ons-table--{{ variant }}{% endfor %}{% else %} ons-table--{{ variants }}{% endif %}{% endif %}" {% if params.sortBy is defined and params.sortBy and 'sortable' in variants %}data-aria-sort="{{ params.sortBy }}" data-aria-asc="{{ params.ariaAsc }}" data-aria-desc="{{ params.ariaDesc }}"{% endif %}>
|
|
12
12
|
{% if params.caption is defined and params.caption %}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<thead class="ons-table__head">
|
|
16
16
|
<tr class="ons-table__row">
|
|
17
17
|
{% for th in params.ths %}
|
|
18
|
-
<th scope="col" class="ons-table__header{{ ' ' + th.thClasses if th.thClasses is defined and th.thClasses }}{{ " ons-table__header--numeric" if th.numeric is defined and th.numeric }}"{% if
|
|
18
|
+
<th scope="col" class="ons-table__header{{ ' ' + th.thClasses if th.thClasses is defined and th.thClasses }}{{ " ons-table__header--numeric" if th.numeric is defined and th.numeric }}"{% if 'sortable' in variants %} aria-sort="{{- th.ariaSort | default('none') -}}"{% endif %}>
|
|
19
19
|
<span {% if 'sortable' in variants %}class="ons-u-vh"{% endif %}>{{- th.value -}}</span>
|
|
20
20
|
{% if 'sortable' in variants %}
|
|
21
21
|
{{
|