@ons/design-system 50.0.1 → 51.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 -13
- 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 +3 -1
- 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/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 +11 -48
- package/components/footer/_macro.spec.js +549 -0
- package/components/header/_macro.njk +2 -2
- 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.spec.js +59 -0
- package/components/mutually-exclusive/_macro.njk +1 -1
- package/components/mutually-exclusive/_macro.spec.js +182 -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 +25 -33
- 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 +1 -1
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
|
|
5
|
+
import axe from '../../tests/helpers/axe';
|
|
6
|
+
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
|
+
|
|
8
|
+
const EXAMPLE_DOCUMENT_LIST_BASIC = {
|
|
9
|
+
url: '#0',
|
|
10
|
+
title: 'Crime and justice',
|
|
11
|
+
description: 'Some description',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const EXAMPLE_DOCUMENT_LIST_WITH_THUMBNAIL = {
|
|
15
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
16
|
+
thumbnail: {
|
|
17
|
+
smallSrc: '/example-small.png',
|
|
18
|
+
largeSrc: '/example-large.png',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const EXAMPLE_DOCUMENT_LIST_WITH_METADATA_FILE = {
|
|
23
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
24
|
+
metadata: {
|
|
25
|
+
file: {
|
|
26
|
+
fileType: 'PDF',
|
|
27
|
+
fileSize: '499KB',
|
|
28
|
+
filePages: '1 page',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE = {
|
|
34
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
35
|
+
metadata: {
|
|
36
|
+
type: {
|
|
37
|
+
text: 'Poster',
|
|
38
|
+
url: '#0',
|
|
39
|
+
ref: 'some ref',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const EXAMPLE_DOCUMENT_LIST_WITH_MULTIPLE = {
|
|
45
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
46
|
+
id: 'some-id',
|
|
47
|
+
thumbnail: {
|
|
48
|
+
smallSrc: '/example-small.png',
|
|
49
|
+
largeSrc: '/example-large.png',
|
|
50
|
+
},
|
|
51
|
+
metadata: {
|
|
52
|
+
type: {
|
|
53
|
+
text: 'Poster',
|
|
54
|
+
url: '#0',
|
|
55
|
+
ref: 'some ref',
|
|
56
|
+
},
|
|
57
|
+
file: {
|
|
58
|
+
fileType: 'PDF',
|
|
59
|
+
fileSize: '499KB',
|
|
60
|
+
filePages: '1 page',
|
|
61
|
+
},
|
|
62
|
+
date: {
|
|
63
|
+
iso: '2022-01-01',
|
|
64
|
+
short: '1 January 2022',
|
|
65
|
+
showPrefix: true,
|
|
66
|
+
prefix: 'Released',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
describe('macro: document list', () => {
|
|
72
|
+
describe('global configuration', () => {
|
|
73
|
+
it('passes jest-axe checks', async () => {
|
|
74
|
+
const $ = cheerio.load(
|
|
75
|
+
renderComponent('document-list', {
|
|
76
|
+
id: 'some-id',
|
|
77
|
+
documents: [EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC],
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const results = await axe($.html());
|
|
82
|
+
expect(results).toHaveNoViolations();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('has the provided `id` attribute', () => {
|
|
86
|
+
const $ = cheerio.load(
|
|
87
|
+
renderComponent('document-list', {
|
|
88
|
+
id: 'some-id',
|
|
89
|
+
documents: [EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC],
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect($('#some-id').length).toBe(1);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('has custom classes applied', () => {
|
|
97
|
+
const $ = cheerio.load(
|
|
98
|
+
renderComponent('document-list', {
|
|
99
|
+
classes: 'custom-class',
|
|
100
|
+
documents: [EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC],
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect($('.ons-document-list').hasClass('custom-class')).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('outputs the correct number of document items', () => {
|
|
108
|
+
const $ = cheerio.load(
|
|
109
|
+
renderComponent('document-list', {
|
|
110
|
+
documents: [EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC, EXAMPLE_DOCUMENT_LIST_BASIC],
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect($('.ons-document-list__item').length).toBe(3);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('has the correct container if `fullWidth`', () => {
|
|
118
|
+
const $ = cheerio.load(
|
|
119
|
+
renderComponent('document-list', {
|
|
120
|
+
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, fullWidth: true }],
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect($('.ons-container').length).toBe(1);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('has the correct container class if `fullWidth` and `wide`', () => {
|
|
128
|
+
const $ = cheerio.load(
|
|
129
|
+
renderComponent('document-list', {
|
|
130
|
+
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, fullWidth: true, wide: true }],
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect($('.ons-container--wide').length).toBe(1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('has the correct container class if `featured`', () => {
|
|
138
|
+
const $ = cheerio.load(
|
|
139
|
+
renderComponent('document-list', {
|
|
140
|
+
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, featured: true }],
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect($('.ons-document-list__item--featured').length).toBe(1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('has the correct class for `showMetadataFirst`', () => {
|
|
148
|
+
const $ = cheerio.load(
|
|
149
|
+
renderComponent('document-list', {
|
|
150
|
+
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, showMetadataFirst: true }],
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
expect($('.ons-document-list__item-header--reverse').length).toBe(1);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('overrides the heading title tag when `titleTag` is provided', () => {
|
|
158
|
+
const $ = cheerio.load(
|
|
159
|
+
renderComponent('document-list', {
|
|
160
|
+
titleTag: 'h1',
|
|
161
|
+
documents: [EXAMPLE_DOCUMENT_LIST_BASIC],
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
const titleTag = $('.ons-document-list__item-title')[0].tagName;
|
|
165
|
+
expect(titleTag).toBe('h1');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('has expected `title`', () => {
|
|
169
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_BASIC] }));
|
|
170
|
+
const title = $('.ons-document-list__item-title a')
|
|
171
|
+
.html()
|
|
172
|
+
.trim();
|
|
173
|
+
expect(title).toBe('Crime and justice');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('has expected `url` for the title', () => {
|
|
177
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_BASIC] }));
|
|
178
|
+
expect($('.ons-document-list__item-title a').attr('href')).toBe('#0');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('has expected `description`', () => {
|
|
182
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_BASIC] }));
|
|
183
|
+
const title = $('.ons-document-list__item-description')
|
|
184
|
+
.html()
|
|
185
|
+
.trim();
|
|
186
|
+
expect(title).toBe('Some description');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('mode: with thumbnail', () => {
|
|
191
|
+
it('passes jest-axe checks', async () => {
|
|
192
|
+
const $ = cheerio.load(
|
|
193
|
+
renderComponent('document-list', {
|
|
194
|
+
id: 'some-id',
|
|
195
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_THUMBNAIL],
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const results = await axe($.html());
|
|
200
|
+
expect(results).toHaveNoViolations();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('has expected `srcset` attribute', () => {
|
|
204
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_THUMBNAIL] }));
|
|
205
|
+
|
|
206
|
+
const srcset = $('.ons-document-list__image-link img').attr('srcset');
|
|
207
|
+
expect(srcset).toBe('/example-small.png 1x, /example-large.png 2x');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('has expected `src` attribute', () => {
|
|
211
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_THUMBNAIL] }));
|
|
212
|
+
|
|
213
|
+
const src = $('.ons-document-list__image-link img').attr('src');
|
|
214
|
+
expect(src).toBe('/example-small.png');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('has the placeholder class if `thumbnail` is true', () => {
|
|
218
|
+
const $ = cheerio.load(
|
|
219
|
+
renderComponent('document-list', {
|
|
220
|
+
documents: [{ ...EXAMPLE_DOCUMENT_LIST_BASIC, thumbnail: true }],
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
expect($('.ons-document-list__image-link').hasClass('ons-document-list__image-link--placeholder')).toBe(true);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('mode: with metadata `file` configuration', () => {
|
|
229
|
+
it('passes jest-axe checks', async () => {
|
|
230
|
+
const $ = cheerio.load(
|
|
231
|
+
renderComponent('document-list', {
|
|
232
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_FILE],
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const results = await axe($.html());
|
|
237
|
+
expect(results).toHaveNoViolations();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('has visually hidden `file` information after the title', () => {
|
|
241
|
+
const $ = cheerio.load(
|
|
242
|
+
renderComponent('document-list', {
|
|
243
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_FILE],
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
const hiddenText = $('.ons-document-list__item-title a .ons-u-vh')
|
|
248
|
+
.text()
|
|
249
|
+
.trim();
|
|
250
|
+
expect(hiddenText).toBe(', PDF document download, 499KB, 1 page');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('has `file` information displayed', () => {
|
|
254
|
+
const $ = cheerio.load(
|
|
255
|
+
renderComponent('document-list', {
|
|
256
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_FILE],
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const hiddenText = $('.ons-document-list__item-attribute')
|
|
261
|
+
.text()
|
|
262
|
+
.trim();
|
|
263
|
+
expect(hiddenText).toBe('PDF, 499KB, 1 page');
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe('mode: with metadata `type` configuration', () => {
|
|
268
|
+
it('passes jest-axe checks', async () => {
|
|
269
|
+
const $ = cheerio.load(
|
|
270
|
+
renderComponent('document-list', {
|
|
271
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE],
|
|
272
|
+
}),
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
const results = await axe($.html());
|
|
276
|
+
expect(results).toHaveNoViolations();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('has the provided `url`', () => {
|
|
280
|
+
const $ = cheerio.load(
|
|
281
|
+
renderComponent('document-list', {
|
|
282
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE],
|
|
283
|
+
}),
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
const url = $('.ons-document-list__attribute-link').attr('href');
|
|
287
|
+
expect(url).toBe('#0');
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('has expected `text`', () => {
|
|
291
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
|
|
292
|
+
const text = $('.ons-document-list__attribute-link > span')
|
|
293
|
+
.text()
|
|
294
|
+
.trim();
|
|
295
|
+
expect(text).toBe('Poster:');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('has expected `ref`', () => {
|
|
299
|
+
const $ = cheerio.load(renderComponent('document-list', { documents: [EXAMPLE_DOCUMENT_LIST_WITH_METADATA_TYPE] }));
|
|
300
|
+
const text = $('.ons-document-list__attribute-link + span')
|
|
301
|
+
.text()
|
|
302
|
+
.trim();
|
|
303
|
+
expect(text).toBe('some ref');
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe('mode: with metadata `date` configuration', () => {
|
|
308
|
+
it('passes jest-axe checks', async () => {
|
|
309
|
+
const $ = cheerio.load(
|
|
310
|
+
renderComponent('document-list', {
|
|
311
|
+
documents: [
|
|
312
|
+
{
|
|
313
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
314
|
+
metadata: {
|
|
315
|
+
date: {
|
|
316
|
+
iso: '2022-01-01',
|
|
317
|
+
short: '1 January 2022',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
}),
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
const results = await axe($.html());
|
|
326
|
+
expect(results).toHaveNoViolations();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('has the default `prefix` text', () => {
|
|
330
|
+
const $ = cheerio.load(
|
|
331
|
+
renderComponent('document-list', {
|
|
332
|
+
documents: [
|
|
333
|
+
{
|
|
334
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
335
|
+
metadata: {
|
|
336
|
+
date: {
|
|
337
|
+
iso: '2022-01-01',
|
|
338
|
+
short: '1 January 2022',
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
}),
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
const text = $('.ons-document-list__item-attribute > span')
|
|
347
|
+
.text()
|
|
348
|
+
.trim();
|
|
349
|
+
expect(text).toBe('Published:');
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('has the visually hidden class for `prefix` text', () => {
|
|
353
|
+
const $ = cheerio.load(
|
|
354
|
+
renderComponent('document-list', {
|
|
355
|
+
documents: [
|
|
356
|
+
{
|
|
357
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
358
|
+
metadata: {
|
|
359
|
+
date: {
|
|
360
|
+
iso: '2022-01-01',
|
|
361
|
+
short: '1 January 2022',
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
}),
|
|
367
|
+
);
|
|
368
|
+
expect($('.ons-document-list__item-attribute > span').hasClass('ons-u-vh')).toBe(true);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('has the provided `prefix` text', () => {
|
|
372
|
+
const $ = cheerio.load(
|
|
373
|
+
renderComponent('document-list', {
|
|
374
|
+
documents: [
|
|
375
|
+
{
|
|
376
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
377
|
+
metadata: {
|
|
378
|
+
date: {
|
|
379
|
+
prefix: 'Released',
|
|
380
|
+
iso: '2022-01-01',
|
|
381
|
+
short: '1 January 2022',
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
}),
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
const text = $('.ons-document-list__item-attribute > span')
|
|
390
|
+
.text()
|
|
391
|
+
.trim();
|
|
392
|
+
expect(text).toBe('Released:');
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('has the correct class for `showPrefix`', () => {
|
|
396
|
+
const $ = cheerio.load(
|
|
397
|
+
renderComponent('document-list', {
|
|
398
|
+
documents: [
|
|
399
|
+
{
|
|
400
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
401
|
+
metadata: {
|
|
402
|
+
date: {
|
|
403
|
+
showPrefix: true,
|
|
404
|
+
iso: '2022-01-01',
|
|
405
|
+
short: '1 January 2022',
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
}),
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
expect($('.ons-document-list__item-attribute > span').hasClass('ons-u-fw-b')).toBe(true);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('has the correct datetime attribute value', () => {
|
|
417
|
+
const $ = cheerio.load(
|
|
418
|
+
renderComponent('document-list', {
|
|
419
|
+
documents: [
|
|
420
|
+
{
|
|
421
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
422
|
+
metadata: {
|
|
423
|
+
date: {
|
|
424
|
+
iso: '2022-01-01',
|
|
425
|
+
short: '1 January 2022',
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
}),
|
|
431
|
+
);
|
|
432
|
+
expect($('time').attr('datetime')).toBe('2022-01-01');
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('has the correct `time` value', () => {
|
|
436
|
+
const $ = cheerio.load(
|
|
437
|
+
renderComponent('document-list', {
|
|
438
|
+
documents: [
|
|
439
|
+
{
|
|
440
|
+
...EXAMPLE_DOCUMENT_LIST_BASIC,
|
|
441
|
+
metadata: {
|
|
442
|
+
date: {
|
|
443
|
+
iso: '2022-01-01',
|
|
444
|
+
short: '1 January 2022',
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
}),
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
const time = $('.ons-document-list__item-attribute time')
|
|
453
|
+
.text()
|
|
454
|
+
.trim();
|
|
455
|
+
expect(time).toBe('1 January 2022');
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
describe('mode: with all parameters', () => {
|
|
460
|
+
it('passes jest-axe checks', async () => {
|
|
461
|
+
const $ = cheerio.load(
|
|
462
|
+
renderComponent('document-list', {
|
|
463
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_MULTIPLE],
|
|
464
|
+
}),
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
const results = await axe($.html());
|
|
468
|
+
expect(results).toHaveNoViolations();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('has the correct document thumbnail class', async () => {
|
|
472
|
+
const $ = cheerio.load(
|
|
473
|
+
renderComponent('document-list', {
|
|
474
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_MULTIPLE],
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
expect($('.ons-document-list__item-image').hasClass('ons-document-list__item-image--file')).toBe(true);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it('has the correct document list class', async () => {
|
|
482
|
+
const $ = cheerio.load(
|
|
483
|
+
renderComponent('document-list', {
|
|
484
|
+
documents: [EXAMPLE_DOCUMENT_LIST_WITH_MULTIPLE],
|
|
485
|
+
}),
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
expect($('.ons-document-list__item-attribute').hasClass('ons-u-mr-no')).toBe(true);
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
});
|