@ons/design-system 72.1.0 → 72.1.2
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 +1 -1
- package/components/accordion/_macro.spec.js +2 -2
- package/components/address-input/_macro.spec.js +245 -322
- package/components/address-input/autosuggest.address.spec.js +16 -14
- package/components/address-output/_macro.spec.js +121 -74
- package/components/address-output/_test_examples.js +8 -0
- package/components/autosuggest/_macro.spec.js +373 -184
- package/components/back-to-top/back-to-top.dom.js +4 -4
- package/components/back-to-top/back-to-top.js +1 -1
- package/components/browser-banner/_macro.spec.js +11 -11
- package/components/button/_button.scss +1 -1
- package/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +405 -351
- package/components/button/example-button-group.njk +1 -0
- package/components/checkboxes/_checkbox.scss +3 -3
- package/components/description-list/_description-list.scss +40 -9
- package/components/description-list/_macro.njk +20 -12
- package/components/description-list/_macro.spec.js +11 -1
- package/components/description-list/example-inline-description-list.njk +58 -0
- package/components/details/_details.scss +1 -2
- package/components/details/example-details-open.njk +10 -0
- package/components/external-link/_macro.spec.js +66 -69
- package/components/external-link/_test_examples.js +4 -0
- package/components/feedback/_macro.spec.js +109 -80
- package/components/feedback/_test_examples.js +17 -0
- package/components/field/_macro.spec.js +106 -69
- package/components/header/_macro.njk +92 -90
- package/components/header/_macro.spec.js +10 -0
- package/components/header/example-header-basic.njk +11 -0
- package/components/hero/_hero.scss +239 -2
- package/components/hero/_macro.njk +7 -0
- package/components/hero/_macro.spec.js +5 -0
- package/components/hero/example-hero-navy-blue.njk +14 -0
- package/components/section-navigation/_macro.njk +9 -6
- package/components/table-of-contents/_macro.njk +3 -3
- package/components/table-of-contents/_macro.spec.js +3 -3
- package/components/table-of-contents/{_toc.scss → _table-of-contents.scss} +1 -1
- package/components/table-of-contents/table-of-contents.dom.js +13 -0
- package/components/table-of-contents/{toc.js → table-of-contents.js} +4 -4
- package/components/table-of-contents/{toc.spec.js → table-of-contents.spec.js} +2 -2
- package/components/tabs/_tabs.scss +10 -11
- package/components/tabs/tabs.js +3 -3
- package/components/timeout-modal/timeout-modal.spec.js +1 -1
- package/css/main.css +1 -1
- package/js/main.js +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -1
- package/scss/utilities/_margin.scss +4 -0
- package/scss/utilities/_padding.scss +4 -0
- package/scss/vars/_colors.scss +2 -0
- package/components/table-of-contents/toc.dom.js +0 -13
|
@@ -189,7 +189,7 @@ describe('script: address-input', () => {
|
|
|
189
189
|
await setTestPage('/test', renderComponent('address-input', EXAMPLE_ADDRESS_INPUT_WITH_API));
|
|
190
190
|
await setTimeout(50);
|
|
191
191
|
|
|
192
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=cf142&limit=10')).toBe(1);
|
|
192
|
+
expect(await apiFaker.getRequestCount('/addresses/eq?input=cf142&limit=10')).toBe(1);
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
describe('when api status is okay', () => {
|
|
@@ -257,8 +257,9 @@ describe('script: address-input', () => {
|
|
|
257
257
|
|
|
258
258
|
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
259
259
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
260
|
+
await setTimeout(50);
|
|
260
261
|
|
|
261
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10')).toBe(1);
|
|
262
|
+
expect(await apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10')).toBe(1);
|
|
262
263
|
});
|
|
263
264
|
|
|
264
265
|
describe('when the value is a full postcode', () => {
|
|
@@ -267,14 +268,15 @@ describe('script: address-input', () => {
|
|
|
267
268
|
|
|
268
269
|
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = 'CF14 2N'));
|
|
269
270
|
await page.type('.ons-js-autosuggest-input', 'T');
|
|
271
|
+
|
|
272
|
+
await setTimeout(100);
|
|
270
273
|
});
|
|
271
274
|
|
|
272
275
|
it('provides expected parameters to the address API where `limit` is 100', async () => {
|
|
273
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202nt&limit=100&groupfullpostcodes=combo')).toBe(1);
|
|
276
|
+
expect(await apiFaker.getRequestCount('/addresses/eq?input=cf14%202nt&limit=100&groupfullpostcodes=combo')).toBe(1);
|
|
274
277
|
});
|
|
275
278
|
|
|
276
279
|
it('has expected suggestion entries', async () => {
|
|
277
|
-
await setTimeout(100);
|
|
278
280
|
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.map((node) => node.textContent.trim()));
|
|
279
281
|
expect(suggestions).toEqual(['196 College Road, Birmingham, B44 8HF', '196 College Road, Whitchurch, Cardiff, CF14 2NZ']);
|
|
280
282
|
});
|
|
@@ -314,7 +316,7 @@ describe('script: address-input', () => {
|
|
|
314
316
|
|
|
315
317
|
it('provides expected parameters to the address API', async () => {
|
|
316
318
|
expect(
|
|
317
|
-
apiFaker.getRequestCount(
|
|
319
|
+
await apiFaker.getRequestCount(
|
|
318
320
|
'/addresses/eq?input=penlline%20road%20whitchurch%20cardiff%20cf14%202nz&limit=100&groupfullpostcodes=combo',
|
|
319
321
|
),
|
|
320
322
|
).toBe(1);
|
|
@@ -336,7 +338,7 @@ describe('script: address-input', () => {
|
|
|
336
338
|
});
|
|
337
339
|
|
|
338
340
|
it('makes expected request when a suggestion is selected', async () => {
|
|
339
|
-
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
341
|
+
expect(await apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
340
342
|
});
|
|
341
343
|
|
|
342
344
|
it('populates manual input fields with address from selection', async () => {
|
|
@@ -360,7 +362,7 @@ describe('script: address-input', () => {
|
|
|
360
362
|
});
|
|
361
363
|
|
|
362
364
|
it('provides expected parameters to the address API', async () => {
|
|
363
|
-
expect(apiFaker.getRequestCount('/addresses/eq?input=cf14%202&limit=10')).toBe(1);
|
|
365
|
+
expect(await apiFaker.getRequestCount('/addresses/eq?input=cf14%202&limit=10')).toBe(1);
|
|
364
366
|
});
|
|
365
367
|
|
|
366
368
|
it('has expected suggestion entries', async () => {
|
|
@@ -380,7 +382,7 @@ describe('script: address-input', () => {
|
|
|
380
382
|
|
|
381
383
|
it('makes expected request', async () => {
|
|
382
384
|
expect(
|
|
383
|
-
apiFaker.getRequestCount(
|
|
385
|
+
await apiFaker.getRequestCount(
|
|
384
386
|
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
385
387
|
),
|
|
386
388
|
).toBe(1);
|
|
@@ -611,7 +613,9 @@ describe('script: address-input', () => {
|
|
|
611
613
|
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
612
614
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
613
615
|
|
|
614
|
-
|
|
616
|
+
await setTimeout(50);
|
|
617
|
+
|
|
618
|
+
expect(await apiFaker.getRequestCount('/addresses/eq?input=196%20colle&limit=10&favourwelsh=true')).toBe(1);
|
|
615
619
|
});
|
|
616
620
|
});
|
|
617
621
|
|
|
@@ -629,7 +633,7 @@ describe('script: address-input', () => {
|
|
|
629
633
|
});
|
|
630
634
|
|
|
631
635
|
it('then the retrieveAddress function will be called', async () => {
|
|
632
|
-
expect(apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
636
|
+
expect(await apiFaker.getRequestCount('/addresses/eq/uprn/100070332099?addresstype=paf')).toBe(1);
|
|
633
637
|
});
|
|
634
638
|
});
|
|
635
639
|
|
|
@@ -735,10 +739,9 @@ describe('script: address-input', () => {
|
|
|
735
739
|
it('provides expected parameters to the address API', async () => {
|
|
736
740
|
await page.$eval('.ons-js-autosuggest-input', (node) => (node.value = '196 coll'));
|
|
737
741
|
await page.type('.ons-js-autosuggest-input', 'e');
|
|
738
|
-
|
|
739
742
|
await setTimeout(50);
|
|
740
743
|
|
|
741
|
-
expect(apiFaker.getRequestCount(searchEndpoint)).toBe(1);
|
|
744
|
+
expect(await apiFaker.getRequestCount(searchEndpoint)).toBe(1);
|
|
742
745
|
});
|
|
743
746
|
|
|
744
747
|
it('requests further information for the selected address from the API with the expected parameters', async () => {
|
|
@@ -746,10 +749,9 @@ describe('script: address-input', () => {
|
|
|
746
749
|
await page.type('.ons-js-autosuggest-input', 'e', { delay: 20 });
|
|
747
750
|
await page.keyboard.press('ArrowDown');
|
|
748
751
|
await page.keyboard.press('Enter');
|
|
749
|
-
|
|
750
752
|
await setTimeout(50);
|
|
751
753
|
|
|
752
|
-
expect(apiFaker.getRequestCount(uprnEndpoint)).toBe(1);
|
|
754
|
+
expect(await apiFaker.getRequestCount(uprnEndpoint)).toBe(1);
|
|
753
755
|
});
|
|
754
756
|
});
|
|
755
757
|
});
|
|
@@ -5,94 +5,141 @@ import * as cheerio from 'cheerio';
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
unit: 'Unit 5',
|
|
10
|
-
organisation: 'Trescos',
|
|
11
|
-
line1: 'Abingdon Road',
|
|
12
|
-
line2: 'Goathill',
|
|
13
|
-
town: 'Barry',
|
|
14
|
-
postcode: 'AB12 6UH',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const EXAMPLE_ADDRESS_OUTPUT_NONE = {};
|
|
18
|
-
|
|
19
|
-
describe('macro: address-output', () => {
|
|
20
|
-
it('passes jest-axe checks', async () => {
|
|
21
|
-
const $ = cheerio.load(renderComponent('address-output', EXAMPLE_ADDRESS_OUTPUT_FULL));
|
|
22
|
-
|
|
23
|
-
const results = await axe($.html());
|
|
24
|
-
expect(results).toHaveNoViolations();
|
|
25
|
-
});
|
|
8
|
+
import { EXAMPLE_ADDRESS_OUTPUT_FULL } from './_test_examples';
|
|
26
9
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
classes: 'extra-class another-extra-class',
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
10
|
+
describe('FOR: Macro: Address-output', () => {
|
|
11
|
+
describe('GIVEN: Params: none', () => {
|
|
12
|
+
describe('WHEN: no parameters are provided', () => {
|
|
13
|
+
const $ = cheerio.load(renderComponent('address-output', {}));
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
test('THEN: renders no lines', () => {
|
|
16
|
+
expect($('.ons-address-output__lines *').length).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
37
19
|
});
|
|
38
20
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
describe('GIVEN: Params: classes', () => {
|
|
22
|
+
describe('WHEN: classes are provided', () => {
|
|
23
|
+
const $ = cheerio.load(
|
|
24
|
+
renderComponent('address-output', {
|
|
25
|
+
...EXAMPLE_ADDRESS_OUTPUT_FULL,
|
|
26
|
+
classes: 'extra-class another-extra-class',
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
test('THEN: renders with additional classes provided', async () => {
|
|
31
|
+
expect($('.ons-address-output').hasClass('extra-class')).toBe(true);
|
|
32
|
+
expect($('.ons-address-output').hasClass('another-extra-class')).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
43
35
|
});
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
])('renders `unit` with %s', (_, params) => {
|
|
49
|
-
const $ = cheerio.load(renderComponent('address-output', params));
|
|
37
|
+
describe('GIVEN: Params: All params', () => {
|
|
38
|
+
describe('WHEN: all address line params are provided', () => {
|
|
39
|
+
const $ = cheerio.load(renderComponent('address-output', EXAMPLE_ADDRESS_OUTPUT_FULL));
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
test('THEN: jest-axe tests pass', async () => {
|
|
42
|
+
const results = await axe($.html());
|
|
43
|
+
expect(results).toHaveNoViolations();
|
|
44
|
+
});
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
])('renders `organisation` with %s', (_, params) => {
|
|
58
|
-
const $ = cheerio.load(renderComponent('address-output', params));
|
|
46
|
+
test('THEN: renders unit with provided text', () => {
|
|
47
|
+
expect($('.ons-address-output__unit').text().trim()).toBe('Unit 5');
|
|
48
|
+
});
|
|
59
49
|
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
test('THEN: renders organisation line with correct text', () => {
|
|
51
|
+
expect($('.ons-address-output__organisation').text().trim()).toBe('Trescos');
|
|
52
|
+
});
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
])('renders `line1` with %s', (_, params) => {
|
|
67
|
-
const $ = cheerio.load(renderComponent('address-output', params));
|
|
54
|
+
test('THEN: renders line1 line with correct text', () => {
|
|
55
|
+
expect($('.ons-address-output__line1').text().trim()).toBe('Abingdon Road');
|
|
56
|
+
});
|
|
68
57
|
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
test('THEN: renders line2 line with correct text', () => {
|
|
59
|
+
expect($('.ons-address-output__line2').text().trim()).toBe('Goathill');
|
|
60
|
+
});
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
])('renders `line2` with %s', (_, params) => {
|
|
76
|
-
const $ = cheerio.load(renderComponent('address-output', params));
|
|
62
|
+
test('THEN: renders the town line with correct text', () => {
|
|
63
|
+
expect($('.ons-address-output__town').text().trim()).toBe('Barry');
|
|
64
|
+
});
|
|
77
65
|
|
|
78
|
-
|
|
66
|
+
test('THEN: renders the postcode line with correct text', () => {
|
|
67
|
+
expect($('.ons-address-output__postcode').text().trim()).toBe('AB12 6UH');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
79
70
|
});
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
describe('GIVEN: Params: single param', () => {
|
|
73
|
+
describe('WHEN: the unit address line is the only parameter provided', () => {
|
|
74
|
+
const $ = cheerio.load(
|
|
75
|
+
renderComponent('address-output', {
|
|
76
|
+
unit: 'Unit 5',
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
test('THEN: renders unit line with correct text', () => {
|
|
81
|
+
expect($('.ons-address-output__unit').text().trim()).toBe('Unit 5');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('WHEN: the organisation address line is the only parameter provided', () => {
|
|
86
|
+
const $ = cheerio.load(
|
|
87
|
+
renderComponent('address-output', {
|
|
88
|
+
organisation: 'Trescos',
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
test('THEN: renders organisation line with correct text', () => {
|
|
93
|
+
expect($('.ons-address-output__organisation').text().trim()).toBe('Trescos');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('WHEN: the line1 address line is the only parameter provided', () => {
|
|
98
|
+
const $ = cheerio.load(
|
|
99
|
+
renderComponent('address-output', {
|
|
100
|
+
line1: 'Abingdon Road',
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
test('THEN: renders line1 line with correct text', () => {
|
|
105
|
+
expect($('.ons-address-output__line1').text().trim()).toBe('Abingdon Road');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('WHEN: the line2 address line is the only parameter provided', () => {
|
|
110
|
+
const $ = cheerio.load(
|
|
111
|
+
renderComponent('address-output', {
|
|
112
|
+
line2: 'Goathill',
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
test('THEN: renders line2 line with correct text', () => {
|
|
117
|
+
expect($('.ons-address-output__line2').text().trim()).toBe('Goathill');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('WHEN: the town address line is the only parameter provided', () => {
|
|
122
|
+
const $ = cheerio.load(
|
|
123
|
+
renderComponent('address-output', {
|
|
124
|
+
town: 'Barry',
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
test('THEN: renders town line with correct text', () => {
|
|
129
|
+
expect($('.ons-address-output__town').text().trim()).toBe('Barry');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('WHEN: the postcode address line is the only parameter provided', () => {
|
|
134
|
+
const $ = cheerio.load(
|
|
135
|
+
renderComponent('address-output', {
|
|
136
|
+
postcode: 'AB12 6UH',
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
test('THEN: renders postcode line with correct text', () => {
|
|
141
|
+
expect($('.ons-address-output__postcode').text().trim()).toBe('AB12 6UH');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
97
144
|
});
|
|
98
145
|
});
|