@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,549 @@
|
|
|
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_OGL_LINK_PARAM = {
|
|
15
|
+
pre: 'All content is available under the',
|
|
16
|
+
link: 'Open Government Licence v3.0',
|
|
17
|
+
url: 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
|
|
18
|
+
post: ', except where otherwise stated',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const EXAMPLE_COLS_PARAM = [
|
|
22
|
+
{
|
|
23
|
+
title: 'First column',
|
|
24
|
+
itemsList: [
|
|
25
|
+
{
|
|
26
|
+
url: '/example-link-a',
|
|
27
|
+
text: 'Example Link A',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Second column',
|
|
33
|
+
itemsList: [
|
|
34
|
+
{
|
|
35
|
+
url: '/example-link-b',
|
|
36
|
+
text: 'Example Link B',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const EXAMPLE_ROWS_PARAM = [
|
|
43
|
+
{
|
|
44
|
+
itemsList: [
|
|
45
|
+
{
|
|
46
|
+
url: '/example-link-a',
|
|
47
|
+
text: 'Example Link A',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
itemsList: [
|
|
53
|
+
{
|
|
54
|
+
url: '/example-link-b',
|
|
55
|
+
text: 'Example Link B',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const EXAMPLE_LEGAL_PARAM = [
|
|
62
|
+
{
|
|
63
|
+
itemsList: [
|
|
64
|
+
{
|
|
65
|
+
url: '/example-legal-link-a',
|
|
66
|
+
text: 'Example Legal Link A',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
itemsList: [
|
|
72
|
+
{
|
|
73
|
+
url: '/example-legal-link-b',
|
|
74
|
+
text: 'Example Legal Link B',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
describe('macro: footer', () => {
|
|
81
|
+
it('decorates container block with `wide` modifier when the `wide` parameter is provided', () => {
|
|
82
|
+
const $ = cheerio.load(
|
|
83
|
+
renderComponent('footer', {
|
|
84
|
+
wide: true,
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const hasClass = $('.ons-container').hasClass('ons-container--wide');
|
|
89
|
+
expect(hasClass).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('does not decorate container block with `wide` modifier when the `wide` parameter is not provided', () => {
|
|
93
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
94
|
+
|
|
95
|
+
const hasClass = $('.ons-container').hasClass('ons-container--wide');
|
|
96
|
+
expect(hasClass).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('has additionally provided `attributes` on the `body` element', () => {
|
|
100
|
+
const $ = cheerio.load(
|
|
101
|
+
renderComponent('footer', {
|
|
102
|
+
attributes: {
|
|
103
|
+
a: '123',
|
|
104
|
+
b: '456',
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect($('.ons-footer__body').attr('a')).toBe('123');
|
|
110
|
+
expect($('.ons-footer__body').attr('b')).toBe('456');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('OGL link', () => {
|
|
114
|
+
const params = {
|
|
115
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
it('passes jest-axe checks', async () => {
|
|
119
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
120
|
+
|
|
121
|
+
const results = await axe($.html());
|
|
122
|
+
expect(results).toHaveNoViolations();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('renders OGL icon', () => {
|
|
126
|
+
const faker = templateFaker();
|
|
127
|
+
const iconsSpy = faker.spy('icons');
|
|
128
|
+
|
|
129
|
+
faker.renderComponent('footer', params);
|
|
130
|
+
|
|
131
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'ogl' }));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('renders raw HTML when `HTML` is provided', () => {
|
|
135
|
+
const $ = cheerio.load(
|
|
136
|
+
renderComponent('footer', {
|
|
137
|
+
OGLLink: {
|
|
138
|
+
...params.OGLLink,
|
|
139
|
+
HTML: '<strong>Bold text.</strong>',
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const licenseHtml = $('.ons-footer__license').html();
|
|
145
|
+
expect(licenseHtml).toContain('<strong>Bold text.</strong>');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('renders link using the external link component', () => {
|
|
149
|
+
const faker = templateFaker();
|
|
150
|
+
const externalLinkSpy = faker.spy('external-link');
|
|
151
|
+
|
|
152
|
+
faker.renderComponent('footer', params);
|
|
153
|
+
|
|
154
|
+
expect(externalLinkSpy.occurrences).toContainEqual(
|
|
155
|
+
expect.objectContaining({
|
|
156
|
+
url: 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
|
|
157
|
+
linkText: 'Open Government Licence v3.0',
|
|
158
|
+
}),
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('renders `post` content when provided', () => {
|
|
163
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
164
|
+
|
|
165
|
+
const licenseHtml = $('.ons-footer__license').html();
|
|
166
|
+
expect(licenseHtml).toContain(', except where otherwise stated');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe('warning', () => {
|
|
171
|
+
const params = {
|
|
172
|
+
footerWarning: 'Footer warning text with <strong>bold</strong> content.',
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
it('passes jest-axe checks', async () => {
|
|
176
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
177
|
+
|
|
178
|
+
const results = await axe($.html());
|
|
179
|
+
expect(results).toHaveNoViolations();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('renders warning element', () => {
|
|
183
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
184
|
+
|
|
185
|
+
const warningHtml = $('.ons-footer__warning').html();
|
|
186
|
+
expect(warningHtml).toContain('Footer warning text with <strong>bold</strong> content.');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('is not rendered when `footerWarning` is not provided', () => {
|
|
190
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
191
|
+
|
|
192
|
+
expect($('.ons-footer__warning').length).toBe(0);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('renders warning text using the panel component', () => {
|
|
196
|
+
const faker = templateFaker();
|
|
197
|
+
const panelSpy = faker.spy('panel');
|
|
198
|
+
|
|
199
|
+
faker.renderComponent('footer', params);
|
|
200
|
+
|
|
201
|
+
expect(panelSpy.occurrences).toContainEqual(
|
|
202
|
+
expect.objectContaining({
|
|
203
|
+
type: 'warn',
|
|
204
|
+
classes: 'ons-panel--warn--footer',
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('copyright', () => {
|
|
211
|
+
const params = {
|
|
212
|
+
copyrightDeclaration: {
|
|
213
|
+
copyright: 'Crown copyright and database rights 2020 OS 100019153.',
|
|
214
|
+
text: 'Use of address data is subject to the terms and conditions.',
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
it('passes jest-axe checks', async () => {
|
|
219
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
220
|
+
|
|
221
|
+
const results = await axe($.html());
|
|
222
|
+
expect(results).toHaveNoViolations();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('renders copyright declaration', () => {
|
|
226
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
227
|
+
|
|
228
|
+
const text = $('.ons-footer__copyright').text();
|
|
229
|
+
expect(text).toBe(
|
|
230
|
+
'© Crown copyright and database rights 2020 OS 100019153. Use of address data is subject to the terms and conditions.',
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('is not rendered when `copyrightDeclaration` is not provided', () => {
|
|
235
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
236
|
+
|
|
237
|
+
expect($('.ons-footer__copyright').length).toBe(0);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('cols', () => {
|
|
242
|
+
const params = {
|
|
243
|
+
cols: EXAMPLE_COLS_PARAM,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
it('passes jest-axe checks', async () => {
|
|
247
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
248
|
+
|
|
249
|
+
const results = await axe($.html());
|
|
250
|
+
expect(results).toHaveNoViolations();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('renders expected column titles', () => {
|
|
254
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
255
|
+
|
|
256
|
+
const titleHeadings = mapAll($('.ons-footer__heading'), node => node.text().trim());
|
|
257
|
+
expect(titleHeadings).toEqual(['First column', 'Second column']);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('renders expected lists using list component', () => {
|
|
261
|
+
const faker = templateFaker();
|
|
262
|
+
const listsSpy = faker.spy('lists');
|
|
263
|
+
|
|
264
|
+
faker.renderComponent('footer', params);
|
|
265
|
+
|
|
266
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
267
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-link-a');
|
|
268
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Link A');
|
|
269
|
+
|
|
270
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
271
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-link-b');
|
|
272
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Link B');
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe('rows', () => {
|
|
277
|
+
const params = {
|
|
278
|
+
rows: EXAMPLE_ROWS_PARAM,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
it('passes jest-axe checks', async () => {
|
|
282
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
283
|
+
|
|
284
|
+
const results = await axe($.html());
|
|
285
|
+
expect(results).toHaveNoViolations();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('renders expected lists using list component', () => {
|
|
289
|
+
const faker = templateFaker();
|
|
290
|
+
const listsSpy = faker.spy('lists');
|
|
291
|
+
|
|
292
|
+
faker.renderComponent('footer', params);
|
|
293
|
+
|
|
294
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
295
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-link-a');
|
|
296
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Link A');
|
|
297
|
+
|
|
298
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
299
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-link-b');
|
|
300
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Link B');
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
describe('legal', () => {
|
|
305
|
+
const params = {
|
|
306
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
it('passes jest-axe checks', async () => {
|
|
310
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
311
|
+
|
|
312
|
+
const results = await axe($.html());
|
|
313
|
+
expect(results).toHaveNoViolations();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('renders expected lists using list component', () => {
|
|
317
|
+
const faker = templateFaker();
|
|
318
|
+
const listsSpy = faker.spy('lists');
|
|
319
|
+
|
|
320
|
+
faker.renderComponent('footer', params);
|
|
321
|
+
|
|
322
|
+
const itemsList1 = listsSpy.occurrences[0].itemsList;
|
|
323
|
+
expect(itemsList1[0]).toHaveProperty('url', '/example-legal-link-a');
|
|
324
|
+
expect(itemsList1[0]).toHaveProperty('text', 'Example Legal Link A');
|
|
325
|
+
|
|
326
|
+
const itemsList2 = listsSpy.occurrences[1].itemsList;
|
|
327
|
+
expect(itemsList2[0]).toHaveProperty('url', '/example-legal-link-b');
|
|
328
|
+
expect(itemsList2[0]).toHaveProperty('text', 'Example Legal Link B');
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
describe('powered by logo', () => {
|
|
333
|
+
describe.each([
|
|
334
|
+
[
|
|
335
|
+
'the `lang` parameter is not provided',
|
|
336
|
+
{},
|
|
337
|
+
{
|
|
338
|
+
iconType: 'ons-logo-en',
|
|
339
|
+
altText: 'Office for National Statistics',
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
'the `lang` parameter is "en"',
|
|
344
|
+
{ lang: 'en' },
|
|
345
|
+
{
|
|
346
|
+
iconType: 'ons-logo-en',
|
|
347
|
+
altText: 'Office for National Statistics',
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
[
|
|
351
|
+
'the `lang` parameter is "cy"',
|
|
352
|
+
{ lang: 'cy' },
|
|
353
|
+
{
|
|
354
|
+
iconType: 'ons-logo-cy',
|
|
355
|
+
altText: 'Swyddfa Ystadegau Gwladol',
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
])('where %s', (_, langParams, defaultIcon) => {
|
|
359
|
+
describe.each([
|
|
360
|
+
[
|
|
361
|
+
'the `poweredBy` and `OGLLink` parameters are provided',
|
|
362
|
+
{
|
|
363
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
364
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
iconType: 'person',
|
|
368
|
+
altText: 'Person alt text',
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
[
|
|
372
|
+
'the `poweredBy` parameter is not provided but the `legal` parameter is provided',
|
|
373
|
+
{
|
|
374
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
375
|
+
},
|
|
376
|
+
defaultIcon,
|
|
377
|
+
],
|
|
378
|
+
[
|
|
379
|
+
'the `poweredBy` parameter is not provided but the `legal` and `OGLLink` parameters are provided',
|
|
380
|
+
{
|
|
381
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
382
|
+
OGLLink: EXAMPLE_OGL_LINK_PARAM,
|
|
383
|
+
},
|
|
384
|
+
defaultIcon,
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
'the `poweredBy` and `legal` parameters are provided',
|
|
388
|
+
{
|
|
389
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
390
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
iconType: 'person',
|
|
394
|
+
altText: 'Person alt text',
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
[
|
|
398
|
+
'the `poweredBy` and `crest` parameters are provided',
|
|
399
|
+
{
|
|
400
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
401
|
+
crest: true,
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
iconType: 'person',
|
|
405
|
+
altText: 'Person alt text',
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
'the `poweredBy`, `legal` and `crest` parameters are provided',
|
|
410
|
+
{
|
|
411
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
412
|
+
legal: EXAMPLE_LEGAL_PARAM,
|
|
413
|
+
crest: true,
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
iconType: 'person',
|
|
417
|
+
altText: 'Person alt text',
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
'the `poweredBy` parameter is not provided but the `legal` and `crest` parameters are provided',
|
|
422
|
+
{
|
|
423
|
+
poweredBy: EXAMPLE_POWERED_BY_PARAM,
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
iconType: 'person',
|
|
427
|
+
altText: 'Person alt text',
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
])('where %s', (_, poweredByParams, expectedIcon) => {
|
|
431
|
+
const params = {
|
|
432
|
+
...langParams,
|
|
433
|
+
...poweredByParams,
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
it('passes jest-axe checks', async () => {
|
|
437
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
438
|
+
|
|
439
|
+
const results = await axe($.html());
|
|
440
|
+
expect(results).toHaveNoViolations();
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('renders the expected icon', () => {
|
|
444
|
+
const faker = templateFaker();
|
|
445
|
+
const iconsSpy = faker.spy('icons');
|
|
446
|
+
|
|
447
|
+
faker.renderComponent('footer', params);
|
|
448
|
+
|
|
449
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining(expectedIcon));
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
describe('save and sign out button', () => {
|
|
456
|
+
const params = {
|
|
457
|
+
button: {
|
|
458
|
+
id: 'save-and-sign-out',
|
|
459
|
+
type: 'button',
|
|
460
|
+
classes: 'extra-class',
|
|
461
|
+
text: 'Save changes and sign out',
|
|
462
|
+
html: '<strong>html</strong>',
|
|
463
|
+
name: 'button-name',
|
|
464
|
+
value: 'button-value',
|
|
465
|
+
attributes: { a: 42 },
|
|
466
|
+
url: 'https://example.com/',
|
|
467
|
+
buttonStyle: 'mobile',
|
|
468
|
+
iconType: 'exit',
|
|
469
|
+
iconPosition: 'before',
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
it('passes jest-axe checks', async () => {
|
|
474
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
475
|
+
|
|
476
|
+
const results = await axe($.html());
|
|
477
|
+
expect(results).toHaveNoViolations();
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it('renders "Save changes and sign out" button using the button component', () => {
|
|
481
|
+
const faker = templateFaker();
|
|
482
|
+
const buttonSpy = faker.spy('button');
|
|
483
|
+
|
|
484
|
+
faker.renderComponent('footer', params);
|
|
485
|
+
|
|
486
|
+
expect(buttonSpy.occurrences).toContainEqual(
|
|
487
|
+
expect.objectContaining({
|
|
488
|
+
...params.button,
|
|
489
|
+
variants: 'ghost',
|
|
490
|
+
}),
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
describe('new tab warning', () => {
|
|
496
|
+
const params = {
|
|
497
|
+
newTabWarning: 'The following links open in a <strong>new tab</strong>',
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
it('passes jest-axe checks', async () => {
|
|
501
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
502
|
+
|
|
503
|
+
const results = await axe($.html());
|
|
504
|
+
expect(results).toHaveNoViolations();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('renders new tab warning element', () => {
|
|
508
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
509
|
+
|
|
510
|
+
const warningHtml = $('.ons-footer__new-tab-warning').html();
|
|
511
|
+
expect(warningHtml).toContain('The following links open in a <strong>new tab</strong>');
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
it('is not rendered when `newTabWarning` is not provided', () => {
|
|
515
|
+
const $ = cheerio.load(renderComponent('footer', {}));
|
|
516
|
+
|
|
517
|
+
expect($('.ons-footer__new-tab-warning').length).toBe(0);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
describe('crest', () => {
|
|
522
|
+
const params = {
|
|
523
|
+
crest: true,
|
|
524
|
+
legal: true,
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
it('passes jest-axe checks', async () => {
|
|
528
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
529
|
+
|
|
530
|
+
const results = await axe($.html());
|
|
531
|
+
expect(results).toHaveNoViolations();
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('renders crest icon when `crest` parameter is provide', () => {
|
|
535
|
+
const faker = templateFaker();
|
|
536
|
+
const iconsSpy = faker.spy('icons');
|
|
537
|
+
|
|
538
|
+
faker.renderComponent('footer', params);
|
|
539
|
+
|
|
540
|
+
expect(iconsSpy.occurrences).toContainEqual(expect.objectContaining({ iconType: 'crest' }));
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it('renders "crest" element', () => {
|
|
544
|
+
const $ = cheerio.load(renderComponent('footer', params));
|
|
545
|
+
|
|
546
|
+
expect($('.ons-footer__crest').length).toBe(1);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% from "components/icons/_macro.njk" import onsIcon %}
|
|
4
4
|
{% from "components/navigation/_macro.njk" import onsNavigation %}
|
|
5
5
|
|
|
6
|
-
{% set title_tag = "h1" if params.
|
|
6
|
+
{% set title_tag = "h1" if params.titleAsH1 else "div" %}
|
|
7
7
|
{% set currentLanguageISOCode = "en" %}
|
|
8
8
|
|
|
9
9
|
{% if params.language is defined and params.language and params.language.languages is defined and params.language.languages %}
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
{% set controlVisibility = false %}
|
|
61
61
|
{% endif %}
|
|
62
62
|
<div class="ons-grid__col ons-col-auto{% if controlVisibility == true %} ons-u-d-no@xxs@{{ breakpoint }}{% endif %}">
|
|
63
|
-
<nav class="ons-header-service-nav ons{{ params.serviceLinks.classes }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
|
|
63
|
+
<nav class="ons-header-service-nav ons-header-service-nav--main {{ params.serviceLinks.classes }}" aria-label="{{ params.serviceLinks.ariaLabel | default("Service links navigation") }}">
|
|
64
64
|
<ul class="ons-header-service-nav__list" aria-label="{{ params.serviceLinks.ariaListLabel | default("Service Links") }}">
|
|
65
65
|
{% for item in (params.serviceLinks.itemsList if params.serviceLinks.itemsList is iterable else params.serviceLinks.itemsList.items()) %}
|
|
66
66
|
<li class="ons-header-service-nav__item">
|