-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathList.test.ts
More file actions
79 lines (70 loc) · 2.22 KB
/
List.test.ts
File metadata and controls
79 lines (70 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { ComponentType, type ListComponent } from '@defra/forms-model'
import { ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js'
import { type Guidance } from '~/src/server/plugins/engine/components/helpers.js'
import { FormModel } from '~/src/server/plugins/engine/models/FormModel.js'
import definition from '~/test/form/definitions/basic.js'
describe('List', () => {
let model: FormModel
beforeEach(() => {
model = new FormModel(definition, {
basePath: 'test'
})
})
describe('Defaults', () => {
let def: ListComponent
let collection: ComponentCollection
let guidance: Guidance
beforeEach(() => {
def = {
title: 'List guidance',
name: 'myComponent',
type: ComponentType.List,
list: 'licenceLengthDays',
options: {}
} satisfies ListComponent
collection = new ComponentCollection([def], { model })
guidance = collection.guidance[0]
})
describe('View model', () => {
it('sets Nunjucks component defaults', () => {
const viewModel = guidance.getViewModel()
expect(viewModel).toEqual(
expect.objectContaining({
attributes: {},
content: {
title: def.title,
text: ''
}
})
)
})
})
describe('List items', () => {
it('returns list items', () => {
expect(guidance).toHaveProperty('items', [
{
id: '52fc51fc-c75a-4b08-9c9e-6bd99b9bc49b',
text: '1 day',
value: 1,
description:
'Valid for 24 hours from the start time that you select'
},
{
id: '56b7b34f-23b3-4446-ac8e-b2443d18588e',
text: '8 day',
value: 8,
description:
'Valid for 8 consecutive days from the start time that you select'
},
{
id: '1af54fbc-eec2-4e1e-bd53-2415abf62677',
text: '12 months',
value: 365,
description:
'12-month licences are now valid for 365 days from their start date and can be purchased at any time during the year'
}
])
})
})
})
})