@ons/design-system 50.0.1 → 53.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/_button.scss +75 -33
- package/components/button/_macro.njk +6 -6
- 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.njk +5 -2
- package/components/external-link/_macro.spec.js +77 -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/_footer.scss +19 -4
- package/components/footer/_macro.njk +106 -137
- package/components/footer/_macro.spec.js +678 -0
- package/components/header/_header.scss +65 -46
- package/components/header/_macro.njk +173 -121
- package/components/header/_macro.spec.js +618 -0
- package/components/hero/_hero.scss +30 -143
- package/components/hero/_macro.njk +12 -23
- package/components/hero/_macro.spec.js +218 -0
- package/components/icons/_macro.njk +258 -30
- 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/_input.scss +8 -0
- 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.njk +1 -1
- package/components/language-selector/_macro.spec.js +137 -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 +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 +45 -38
- package/components/navigation/_macro.spec.js +329 -0
- package/components/navigation/_navigation.scss +20 -4
- 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 +14 -21
- package/components/related-content/_macro.spec.js +133 -0
- package/components/related-content/_section-macro.njk +10 -0
- package/components/related-content/_section-macro.spec.js +43 -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 +6 -4
- 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 +3 -1
- package/css/ids.css +2 -0
- package/css/main.css +1 -1
- package/img/dummy-brand-logo.svg +1 -0
- package/js/cookies-settings.spec.js +154 -0
- package/layout/_template.njk +7 -4
- package/package.json +10 -23
- package/scripts/main.es5.js +2 -2
- package/scripts/main.js +1 -1
- package/scss/ids.scss +2 -0
- package/scss/settings/_census.scss +141 -0
- package/scss/settings/_ids.scss +48 -0
- package/scss/utilities/_margin.scss +1 -0
- package/scss/vars/_colors.scss +5 -2
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
2
|
+
|
|
3
|
+
import * as cheerio from 'cheerio';
|
|
4
|
+
|
|
5
|
+
import axe from '../../tests/helpers/axe';
|
|
6
|
+
import { mapAll } from '../../tests/helpers/cheerio';
|
|
7
|
+
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
8
|
+
|
|
9
|
+
const EXAMPLE_POWERED_BY_PARAM = {
|
|
10
|
+
logo: 'person',
|
|
11
|
+
alt: 'Person alt text',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM = {
|
|
15
|
+
logo: 'person',
|
|
16
|
+
alt: 'Person alt text',
|
|
17
|
+
partnership: 'Prefix text string',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const EXAMPLE_OGL_LINK_PARAM = {
|
|
21
|
+
pre: 'All content is available under the',
|
|
22
|
+
link: 'Open Government Licence v3.0',
|
|
23
|
+
url: 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
|
|
24
|
+
post: ', except where otherwise stated',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const EXAMPLE_COLS_PARAM = [
|
|
28
|
+
{
|
|
29
|
+
title: 'First column',
|
|
30
|
+
itemsList: [
|
|
31
|
+
{
|
|
32
|
+
url: '/example-link-a',
|
|
33
|
+
text: 'Example Link A',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Second column',
|
|
39
|
+
itemsList: [
|
|
40
|
+
{
|
|
41
|
+
url: '/example-link-b',
|
|
42
|
+
text: 'Example Link B',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const EXAMPLE_ROWS_PARAM = [
|
|
49
|
+
{
|
|
50
|
+
itemsList: [
|
|
51
|
+
{
|
|
52
|
+
url: '/example-link-a',
|
|
53
|
+
text: 'Example Link A',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
itemsList: [
|
|
59
|
+
{
|
|
60
|
+
url: '/example-link-b',
|
|
61
|
+
text: 'Example Link B',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const EXAMPLE_LEGAL_PARAM = [
|
|
68
|
+
{
|
|
69
|
+
itemsList: [
|
|
70
|
+
{
|
|
71
|
+
url: '/example-legal-link-a',
|
|
72
|
+
text: 'Example Legal Link A',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
itemsList: [
|
|
78
|
+
{
|
|
79
|
+
url: '/example-legal-link-b',
|
|
80
|
+
text: 'Example Legal Link B',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
describe('macro: footer', () => {
|
|
87
|
+
it('decorates container block with `wide` modifier when the `wide` parameter is provided', () => {
|
|
88
|
+
const $ = cheerio.load(
|
|
89
|
+
renderComponent('footer', {
|
|
90
|
+
wide: true,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const hasClass = $('.ons-container').hasClass('ons-container--wide');
|
|
95
|
+
expect(hasClass).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('does not decorate container block with `wide` modifier when the `wide` parameter is not provided', () => {
|
|
99
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
100
|
+
|
|
101
|
+
const hasClass = $('.ons-container').hasClass('ons-container--wide');
|
|
102
|
+
expect(hasClass).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('has additionally provided `attributes` on the `body` element', () => {
|
|
106
|
+
const $ = cheerio.load(
|
|
107
|
+
renderComponent('footer', {
|
|
108
|
+
attributes: {
|
|
109
|
+
a: '123',
|
|
110
|
+
b: '456',
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
expect($('.ons-footer__body').attr('a')).toBe('123');
|
|
116
|
+
expect($('.ons-footer__body').attr('b')).toBe('456');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('OGL link', () => {
|
|
120
|
+
const params = {
|
|
121
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
it('passes jest-axe checks', async () => {
|
|
125
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
126
|
+
|
|
127
|
+
const results = await axe($.html());
|
|
128
|
+
expect(results).toHaveNoViolations();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('renders OGL icon', () => {
|
|
132
|
+
const faker = templateFaker();
|
|
133
|
+
const iconsSpy = faker.spy('icons');
|
|
134
|
+
|
|
135
|
+
faker.renderComponent('footer', params);
|
|
136
|
+
|
|
137
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'ogl' }));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('renders raw HTML when `HTML` is provided', () => {
|
|
141
|
+
const $ = cheerio.load(
|
|
142
|
+
renderComponent('footer', {
|
|
143
|
+
OGLLink: {
|
|
144
|
+
...params.OGLLink,
|
|
145
|
+
HTML: '<strong>Bold text.</strong>',
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const licenseHtml = $('.ons-footer__license').html();
|
|
151
|
+
expect(licenseHtml).toContain('<strong>Bold text.</strong>');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('renders link using the external link component', () => {
|
|
155
|
+
const faker = templateFaker();
|
|
156
|
+
const externalLinkSpy = faker.spy('external-link');
|
|
157
|
+
|
|
158
|
+
faker.renderComponent('footer', params);
|
|
159
|
+
|
|
160
|
+
expect(externalLinkSpy.occurrences).toContainEqual(
|
|
161
|
+
expect.objectContaining({
|
|
162
|
+
url: 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
|
|
163
|
+
linkText: 'Open Government Licence v3.0',
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('renders `post` content when provided', () => {
|
|
169
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
170
|
+
|
|
171
|
+
const licenseHtml = $('.ons-footer__license').html();
|
|
172
|
+
expect(licenseHtml).toContain(', except where otherwise stated');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('renders welsh `post` content when `lang:cy` provided and `OGLLink` is "true"', () => {
|
|
176
|
+
const $ = cheerio.load(
|
|
177
|
+
renderComponent('footer', {
|
|
178
|
+
lang: 'cy',
|
|
179
|
+
OGLLink: true,
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const licenseHtml = $('.ons-footer__license').html();
|
|
184
|
+
expect(licenseHtml).toContain(', oni bai y nodir fel arall');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('warning', () => {
|
|
189
|
+
const params = {
|
|
190
|
+
footerWarning: 'Footer warning text with <strong>bold</strong> content.',
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
it('passes jest-axe checks', async () => {
|
|
194
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
195
|
+
|
|
196
|
+
const results = await axe($.html());
|
|
197
|
+
expect(results).toHaveNoViolations();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('renders warning element', () => {
|
|
201
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
202
|
+
|
|
203
|
+
const warningHtml = $('.ons-footer__warning').html();
|
|
204
|
+
expect(warningHtml).toContain('Footer warning text with <strong>bold</strong> content.');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('is not rendered when `footerWarning` is not provided', () => {
|
|
208
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
209
|
+
|
|
210
|
+
expect($('.ons-footer__warning').length).toBe(0);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('renders warning text using the panel component', () => {
|
|
214
|
+
const faker = templateFaker();
|
|
215
|
+
const panelSpy = faker.spy('panel');
|
|
216
|
+
|
|
217
|
+
faker.renderComponent('footer', params);
|
|
218
|
+
|
|
219
|
+
expect(panelSpy.occurrences).toContainEqual(
|
|
220
|
+
expect.objectContaining({
|
|
221
|
+
type: 'warn',
|
|
222
|
+
classes: 'ons-panel--warn--footer',
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('copyright', () => {
|
|
229
|
+
const params = {
|
|
230
|
+
copyrightDeclaration: {
|
|
231
|
+
copyright: 'Crown copyright and database rights 2020 OS 100019153.',
|
|
232
|
+
text: 'Use of address data is subject to the terms and conditions.',
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
it('passes jest-axe checks', async () => {
|
|
237
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
238
|
+
|
|
239
|
+
const results = await axe($.html());
|
|
240
|
+
expect(results).toHaveNoViolations();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('renders copyright declaration', () => {
|
|
244
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
245
|
+
|
|
246
|
+
const text = $('.ons-footer__copyright').text();
|
|
247
|
+
expect(text).toBe(
|
|
248
|
+
'© Crown copyright and database rights 2020 OS 100019153. Use of address data is subject to the terms and conditions.',
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('is not rendered when `copyrightDeclaration` is not provided', () => {
|
|
253
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
254
|
+
|
|
255
|
+
expect($('.ons-footer__copyright').length).toBe(0);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('cols', () => {
|
|
260
|
+
const params = {
|
|
261
|
+
cols: EXAMPLE_COLS_PARAM,
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
it('passes jest-axe checks', async () => {
|
|
265
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
266
|
+
|
|
267
|
+
const results = await axe($.html());
|
|
268
|
+
expect(results).toHaveNoViolations();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('renders expected column titles', () => {
|
|
272
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
273
|
+
|
|
274
|
+
const titleHeadings = mapAll($('.ons-footer__heading'), node => node.text().trim());
|
|
275
|
+
expect(titleHeadings).toEqual(['First column', 'Second column']);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('renders expected lists using list component', () => {
|
|
279
|
+
const faker = templateFaker();
|
|
280
|
+
const listsSpy = faker.spy('lists');
|
|
281
|
+
|
|
282
|
+
faker.renderComponent('footer', params);
|
|
283
|
+
|
|
284
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
285
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-link-a');
|
|
286
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Link A');
|
|
287
|
+
|
|
288
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
289
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-link-b');
|
|
290
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Link B');
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe('rows', () => {
|
|
295
|
+
const params = {
|
|
296
|
+
rows: EXAMPLE_ROWS_PARAM,
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
it('passes jest-axe checks', async () => {
|
|
300
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
301
|
+
|
|
302
|
+
const results = await axe($.html());
|
|
303
|
+
expect(results).toHaveNoViolations();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('renders expected lists using list component', () => {
|
|
307
|
+
const faker = templateFaker();
|
|
308
|
+
const listsSpy = faker.spy('lists');
|
|
309
|
+
|
|
310
|
+
faker.renderComponent('footer', params);
|
|
311
|
+
|
|
312
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
313
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-link-a');
|
|
314
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Link A');
|
|
315
|
+
|
|
316
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
317
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-link-b');
|
|
318
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Link B');
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
describe('legal', () => {
|
|
323
|
+
const params = {
|
|
324
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
it('passes jest-axe checks', async () => {
|
|
328
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
329
|
+
|
|
330
|
+
const results = await axe($.html());
|
|
331
|
+
expect(results).toHaveNoViolations();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('renders expected lists using list component', () => {
|
|
335
|
+
const faker = templateFaker();
|
|
336
|
+
const listsSpy = faker.spy('lists');
|
|
337
|
+
|
|
338
|
+
faker.renderComponent('footer', params);
|
|
339
|
+
|
|
340
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
341
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-legal-link-a');
|
|
342
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Legal Link A');
|
|
343
|
+
|
|
344
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
345
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-legal-link-b');
|
|
346
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Legal Link B');
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
describe('powered by logo', () => {
|
|
351
|
+
describe.each([
|
|
352
|
+
[
|
|
353
|
+
'the `lang` parameter is not provided',
|
|
354
|
+
{},
|
|
355
|
+
{
|
|
356
|
+
iconType: 'ons-logo-en',
|
|
357
|
+
altText: 'Office for National Statistics',
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
[
|
|
361
|
+
'the `lang` parameter is "en"',
|
|
362
|
+
{ lang: 'en' },
|
|
363
|
+
{
|
|
364
|
+
iconType: 'ons-logo-en',
|
|
365
|
+
altText: 'Office for National Statistics',
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
'the `lang` parameter is "cy"',
|
|
370
|
+
{ lang: 'cy' },
|
|
371
|
+
{
|
|
372
|
+
iconType: 'ons-logo-cy',
|
|
373
|
+
altText: 'Swyddfa Ystadegau Gwladol',
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
])('where %s', (_, langParams, defaultIcon) => {
|
|
377
|
+
describe.each([
|
|
378
|
+
[
|
|
379
|
+
'the `poweredBy` and `OGLLink` parameters are provided',
|
|
380
|
+
{
|
|
381
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
382
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
iconType: 'person',
|
|
386
|
+
altText: 'Person alt text',
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
[
|
|
390
|
+
'the `poweredBy.partnership` and `OGLLink` parameters are provided',
|
|
391
|
+
{
|
|
392
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
393
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
iconType: 'person',
|
|
397
|
+
altText: 'Person alt text',
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
[
|
|
401
|
+
'the `poweredBy` parameter is not provided but the `legal` parameter is provided',
|
|
402
|
+
{
|
|
403
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
404
|
+
},
|
|
405
|
+
defaultIcon,
|
|
406
|
+
],
|
|
407
|
+
[
|
|
408
|
+
'the `poweredBy` parameter is not provided but the `legal` and `OGLLink` parameters are provided',
|
|
409
|
+
{
|
|
410
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
411
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
412
|
+
},
|
|
413
|
+
defaultIcon,
|
|
414
|
+
],
|
|
415
|
+
[
|
|
416
|
+
'the `poweredBy` and `legal` parameters are provided',
|
|
417
|
+
{
|
|
418
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
419
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
iconType: 'person',
|
|
423
|
+
altText: 'Person alt text',
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
[
|
|
427
|
+
'the `poweredBy.partnership` and `legal` parameters are provided',
|
|
428
|
+
{
|
|
429
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
430
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
iconType: 'person',
|
|
434
|
+
altText: 'Person alt text',
|
|
435
|
+
},
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
'the `poweredBy` and `crest` parameters are provided',
|
|
439
|
+
{
|
|
440
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
441
|
+
crest: true,
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
iconType: 'person',
|
|
445
|
+
altText: 'Person alt text',
|
|
446
|
+
},
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
'the `poweredBy.partnership` and `crest` parameters are provided',
|
|
450
|
+
{
|
|
451
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
452
|
+
crest: true,
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
iconType: 'person',
|
|
456
|
+
altText: 'Person alt text',
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
[
|
|
460
|
+
'the `poweredBy`, `legal` and `crest` parameters are provided',
|
|
461
|
+
{
|
|
462
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
463
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
464
|
+
crest: true,
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
iconType: 'person',
|
|
468
|
+
altText: 'Person alt text',
|
|
469
|
+
},
|
|
470
|
+
],
|
|
471
|
+
[
|
|
472
|
+
'the `poweredBy.partnership`, `legal` and `crest` parameters are provided',
|
|
473
|
+
{
|
|
474
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
475
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
476
|
+
crest: true,
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
iconType: 'person',
|
|
480
|
+
altText: 'Person alt text',
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
'the `poweredBy` parameter is provided but the `legal` and `crest` parameters are not provided',
|
|
485
|
+
{
|
|
486
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
iconType: 'person',
|
|
490
|
+
altText: 'Person alt text',
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
'the `poweredBy.partnership` parameter is provided but the `legal` and `crest` parameters are not provided',
|
|
495
|
+
{
|
|
496
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
iconType: 'person',
|
|
500
|
+
altText: 'Person alt text',
|
|
501
|
+
},
|
|
502
|
+
],
|
|
503
|
+
])('where %s', (_, poweredByParams, expectedIcon) => {
|
|
504
|
+
const params = {
|
|
505
|
+
...langParams,
|
|
506
|
+
...poweredByParams,
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
it('passes jest-axe checks', async () => {
|
|
510
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
511
|
+
|
|
512
|
+
const results = await axe($.html());
|
|
513
|
+
expect(results).toHaveNoViolations();
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
it('renders the expected icon', () => {
|
|
517
|
+
const faker = templateFaker();
|
|
518
|
+
const iconsSpy = faker.spy('icons');
|
|
519
|
+
|
|
520
|
+
faker.renderComponent('footer', params);
|
|
521
|
+
|
|
522
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining(expectedIcon));
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
describe('save and sign out button', () => {
|
|
529
|
+
const params = {
|
|
530
|
+
button: {
|
|
531
|
+
id: 'save-and-sign-out',
|
|
532
|
+
type: 'button',
|
|
533
|
+
classes: 'extra-class',
|
|
534
|
+
text: 'Save changes and sign out',
|
|
535
|
+
html: '<strong>html</strong>',
|
|
536
|
+
name: 'button-name',
|
|
537
|
+
value: 'button-value',
|
|
538
|
+
attributes: { a: 42 },
|
|
539
|
+
url: 'https://example.com/',
|
|
540
|
+
buttonStyle: 'mobile',
|
|
541
|
+
iconType: 'exit',
|
|
542
|
+
iconPosition: 'before',
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
it('passes jest-axe checks', async () => {
|
|
547
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
548
|
+
|
|
549
|
+
const results = await axe($.html());
|
|
550
|
+
expect(results).toHaveNoViolations();
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it('renders "Save changes and sign out" button using the button component', () => {
|
|
554
|
+
const faker = templateFaker();
|
|
555
|
+
const buttonSpy = faker.spy('button');
|
|
556
|
+
|
|
557
|
+
faker.renderComponent('footer', params);
|
|
558
|
+
|
|
559
|
+
expect(buttonSpy.occurrences).toContainEqual(
|
|
560
|
+
expect.objectContaining({
|
|
561
|
+
...params.button,
|
|
562
|
+
variants: 'ghost',
|
|
563
|
+
}),
|
|
564
|
+
);
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
describe('new tab warning', () => {
|
|
569
|
+
const params = {
|
|
570
|
+
newTabWarning: 'The following links open in a <strong>new tab</strong>',
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
it('passes jest-axe checks', async () => {
|
|
574
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
575
|
+
|
|
576
|
+
const results = await axe($.html());
|
|
577
|
+
expect(results).toHaveNoViolations();
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it('renders new tab warning element', () => {
|
|
581
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
582
|
+
|
|
583
|
+
const warningHtml = $('.ons-footer__new-tab-warning').html();
|
|
584
|
+
expect(warningHtml).toContain('The following links open in a <strong>new tab</strong>');
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('is not rendered when `newTabWarning` is not provided', () => {
|
|
588
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
589
|
+
|
|
590
|
+
expect($('.ons-footer__new-tab-warning').length).toBe(0);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
describe('crest', () => {
|
|
595
|
+
const params = {
|
|
596
|
+
crest: true,
|
|
597
|
+
legal: true,
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
it('passes jest-axe checks', async () => {
|
|
601
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
602
|
+
|
|
603
|
+
const results = await axe($.html());
|
|
604
|
+
expect(results).toHaveNoViolations();
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it('renders crest icon when `crest` parameter is provided', () => {
|
|
608
|
+
const faker = templateFaker();
|
|
609
|
+
const iconsSpy = faker.spy('icons');
|
|
610
|
+
|
|
611
|
+
faker.renderComponent('footer', params);
|
|
612
|
+
|
|
613
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'crest' }));
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
it('renders "crest" element', () => {
|
|
617
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
618
|
+
|
|
619
|
+
expect($('.ons-footer__crest').length).toBe(1);
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
describe('partnership', () => {
|
|
624
|
+
const params = {
|
|
625
|
+
poweredBy: EXAMPLE_POWERED_BY_WITH_PARTNERSHIP_PARAM,
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
it('passes jest-axe checks', async () => {
|
|
629
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
630
|
+
|
|
631
|
+
const results = await axe($.html());
|
|
632
|
+
expect(results).toHaveNoViolations();
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
it('renders ONS icon when `partnership` parameter is provided', () => {
|
|
636
|
+
const faker = templateFaker();
|
|
637
|
+
const iconsSpy = faker.spy('icons');
|
|
638
|
+
|
|
639
|
+
faker.renderComponent('footer', params);
|
|
640
|
+
|
|
641
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'ons-logo-en' }));
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
it('renders "poweredBy" icon when `partnership` parameter is provided', () => {
|
|
645
|
+
const faker = templateFaker();
|
|
646
|
+
const iconsSpy = faker.spy('icons');
|
|
647
|
+
|
|
648
|
+
faker.renderComponent('footer', params);
|
|
649
|
+
|
|
650
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'person' }));
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
it('renders "poweredBy" element when `partnership` parameter is provided', () => {
|
|
654
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
655
|
+
|
|
656
|
+
expect($('.ons-footer__poweredby').length).toBe(1);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it('renders "partnership" and "prefix" elements when `partnership` parameter is provided', () => {
|
|
660
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
661
|
+
|
|
662
|
+
expect($('.ons-footer__partnership').length).toBe(1);
|
|
663
|
+
expect($('.ons-footer__partnership-prefix').length).toBe(1);
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
it('does not render "partnership" element when `partnership` parameter is not provided', () => {
|
|
667
|
+
const params = {
|
|
668
|
+
poweredBy: {
|
|
669
|
+
logo: 'person',
|
|
670
|
+
alt: 'Person alt text',
|
|
671
|
+
},
|
|
672
|
+
};
|
|
673
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
674
|
+
|
|
675
|
+
expect($('.ons-footer__partnership').length).toBe(0);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|