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