Skip to content

Commit f2e1542

Browse files
Fix summary view model (repeater) tests
1 parent acde1a6 commit f2e1542

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/server/plugins/engine/models/SummaryViewModel.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ describe('SummaryViewModel', () => {
6767
} satisfies FormState,
6868
keys: [
6969
'How would you like to receive your pizza?',
70-
'Pizzas',
70+
'Pizza',
7171
'How you would like to receive your pizza',
72-
'Pizzas',
72+
'Pizza',
7373
'Pizza'
7474
],
7575
values: ['Collection', 'Not provided'],
@@ -91,13 +91,13 @@ describe('SummaryViewModel', () => {
9191
} satisfies FormState,
9292
keys: [
9393
'How would you like to receive your pizza?',
94-
'Pizza added',
94+
'Pizza',
9595
'How you would like to receive your pizza',
96-
'Pizzas',
96+
'Pizza',
9797
'Pizza'
9898
],
99-
values: ['Delivery', 'You added 1 Pizza'],
100-
answers: ['Delivery', 'You added 1 Pizza'],
99+
values: ['Delivery', 'You have added 1 answer'],
100+
answers: ['Delivery', 'You have added 1 answer'],
101101
names: ['orderType', 'pizza']
102102
},
103103
{
@@ -120,13 +120,13 @@ describe('SummaryViewModel', () => {
120120
} satisfies FormState,
121121
keys: [
122122
'How would you like to receive your pizza?',
123-
'Pizzas added',
123+
'Pizza',
124124
'How you would like to receive your pizza',
125-
'Pizzas',
125+
'Pizza',
126126
'Pizza'
127127
],
128-
values: ['Delivery', 'You added 2 Pizzas'],
129-
answers: ['Delivery', 'You added 2 Pizzas'],
128+
values: ['Delivery', 'You have added 2 answers'],
129+
answers: ['Delivery', 'You have added 2 answers'],
130130
names: ['orderType', 'pizza']
131131
}
132132
])(
@@ -326,7 +326,7 @@ describe('SummaryViewModel', () => {
326326
expect(details1.items[0]).toMatchObject({
327327
name: 'pizza',
328328
value: '',
329-
title: 'Pizzas',
329+
title: 'Pizza',
330330
label: 'Pizza'
331331
})
332332

src/server/plugins/engine/models/SummaryViewModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function ItemRepeat(
192192
name,
193193
label: title,
194194
title,
195-
value: `You have added ${values.length} ${unit}`,
195+
value: values.length ? `You have added ${values.length} ${unit}` : '',
196196
href: getPageHref(page, options.path, {
197197
returnUrl: getPageHref(page, page.getSummaryPath())
198198
}),

src/server/plugins/engine/models/__snapshots__/SummaryViewModel.test.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`SummaryViewModel Check answers (0 items) should use correct summary lab
55
{
66
"label": "Pizza",
77
"name": "pizza",
8-
"title": "Pizzas",
8+
"title": "Pizza",
99
"value": "",
1010
},
1111
{
@@ -22,8 +22,8 @@ exports[`SummaryViewModel Check answers (1 item) should use correct summary labe
2222
{
2323
"label": "Pizza",
2424
"name": "pizza",
25-
"title": "Pizza added",
26-
"value": "You added 1 Pizza",
25+
"title": "Pizza",
26+
"value": "You have added 1 answer",
2727
},
2828
{
2929
"label": "How would you like to receive your pizza?",
@@ -39,8 +39,8 @@ exports[`SummaryViewModel Check answers (2 items) should use correct summary lab
3939
{
4040
"label": "Pizza",
4141
"name": "pizza",
42-
"title": "Pizzas added",
43-
"value": "You added 2 Pizzas",
42+
"title": "Pizza",
43+
"value": "You have added 2 answers",
4444
},
4545
{
4646
"label": "How would you like to receive your pizza?",

0 commit comments

Comments
 (0)