@@ -6,185 +6,177 @@ describe('BrainInjury', () => {
6
6
const application = applicationFactory . build ( { person : personFactory . build ( { name : 'Roger Smith' } ) } )
7
7
8
8
describe ( 'title' , ( ) => {
9
- it ( 'personalises the page title' , ( ) => {
10
- const page = new BrainInjury ( { } , application )
9
+ itShouldHaveNextValue ( new BrainInjury ( { } , application ) , 'other-health' )
10
+ itShouldHavePreviousValue ( new BrainInjury ( { } , application ) , 'learning-difficulties' )
11
11
12
- expect ( page . title ) . toEqual ( 'Brain injury needs for Roger Smith' )
13
- } )
14
- } )
12
+ describe ( 'errors' , ( ) => {
13
+ describe ( 'when top-level questions are unanswered' , ( ) => {
14
+ const page = new BrainInjury ( { } , application )
15
15
16
- describe ( 'questions' , ( ) => {
17
- const page = new BrainInjury ( { } , application )
16
+ it ( 'includes a validation error for _hasBrainInjury_' , ( ) => {
17
+ expect ( page . errors ( ) ) . toHaveProperty (
18
+ 'hasBrainInjury' ,
19
+ `Select if they have a brain injury, or select 'I do not know'` ,
20
+ )
21
+ } )
18
22
19
- describe ( 'hasBrainInjury' , ( ) => {
20
- it ( 'has a question' , ( ) => {
21
- expect ( page . questions . hasBrainInjury . question ) . toBeDefined ( )
22
- } )
23
- it ( 'has one follow-up question' , ( ) => {
24
- expect ( page . questions . injuryDetail . question ) . toBeDefined ( )
25
- } )
26
- } )
23
+ it ( 'includes a validation error for _supportNeeded_' , ( ) => {
24
+ expect ( page . errors ( ) ) . toHaveProperty (
25
+ 'supportNeeded' ,
26
+ `Select if they need any support, or select 'I do not know'` ,
27
+ )
28
+ } )
27
29
28
- describe ( 'isVulnerable' , ( ) => {
29
- it ( 'has a question' , ( ) => {
30
- expect ( page . questions . isVulnerable . question ) . toBeDefined ( )
31
- } )
32
- it ( 'has one follow-up question' , ( ) => {
33
- expect ( page . questions . vulnerabilityDetail . question ) . toBeDefined ( )
34
- } )
35
- } )
30
+ it ( 'includes a validation error for _receivingTreatment_' , ( ) => {
31
+ expect ( page . errors ( ) ) . toHaveProperty (
32
+ 'receivingTreatment' ,
33
+ `Select if they receive any treatment or medication, or select 'I do not know'` ,
34
+ )
35
+ } )
36
36
37
- describe ( 'hasDifficultyInteracting' , ( ) => {
38
- it ( 'has a question' , ( ) => {
39
- expect ( page . questions . hasDifficultyInteracting . question ) . toBeDefined ( )
40
- } )
41
- it ( 'has one follow-up question' , ( ) => {
42
- expect ( page . questions . interactionDetail . question ) . toBeDefined ( )
43
- } )
44
- } )
37
+ it ( 'includes a validation error for _isVulnerable_' , ( ) => {
38
+ expect ( page . errors ( ) ) . toHaveProperty (
39
+ 'isVulnerable' ,
40
+ `Select if they are vulnerable, or select 'I do not know'` ,
41
+ )
42
+ } )
45
43
46
- describe ( 'requiresAdditionalSupport ', ( ) => {
47
- it ( 'has a question' , ( ) => {
48
- expect ( page . questions . requiresAdditionalSupport . question ) . toBeDefined ( )
49
- } )
50
- it ( 'has one follow-up question' , ( ) => {
51
- expect ( page . questions . addSupportDetail . question ) . toBeDefined ( )
44
+ it ( 'includes a validation error for _hasDifficultyInteracting_ ', ( ) => {
45
+ expect ( page . errors ( ) ) . toHaveProperty (
46
+ 'hasDifficultyInteracting' ,
47
+ `Select if they have difficulties interacting with other people, or select 'I do not know'` ,
48
+ )
49
+ } )
52
50
} )
53
- } )
54
- } )
55
-
56
- itShouldHaveNextValue ( new BrainInjury ( { } , application ) , 'other-health' )
57
- itShouldHavePreviousValue ( new BrainInjury ( { } , application ) , 'learning-difficulties' )
58
51
59
- describe ( 'errors' , ( ) => {
60
- describe ( 'when top-level questions are unanswered' , ( ) => {
61
- const page = new BrainInjury ( { } , application )
52
+ describe ( 'when _hasBrainInjury_ is YES' , ( ) => {
53
+ const page = new BrainInjury ( { hasBrainInjury : 'yes' } , application )
62
54
63
- it ( 'includes a validation error for _hasBrainInjury_' , ( ) => {
64
- expect ( page . errors ( ) ) . toHaveProperty ( 'hasBrainInjury' , 'Confirm whether they have a brain injury' )
55
+ describe ( 'and _injuryDetail_ is UNANSWERED' , ( ) => {
56
+ it ( 'includes a validation error for _injuryDetail_' , ( ) => {
57
+ expect ( page . errors ( ) ) . toHaveProperty ( 'injuryDetail' , 'Enter details of their brain injury and needs' )
58
+ } )
59
+ } )
65
60
} )
66
61
67
- it ( 'includes a validation error for _isVulnerable_' , ( ) => {
68
- expect ( page . errors ( ) ) . toHaveProperty ( 'isVulnerable' , 'Confirm whether they are vulnerable' )
69
- } )
62
+ describe ( 'when _supportNeeded_ is YES' , ( ) => {
63
+ const page = new BrainInjury ( { supportNeeded : 'yes' } , application )
70
64
71
- it ( 'includes a validation error for _hasDifficultyInteracting_' , ( ) => {
72
- expect ( page . errors ( ) ) . toHaveProperty (
73
- 'hasDifficultyInteracting' ,
74
- 'Confirm whether they have difficulties interacting' ,
75
- )
76
- } )
77
-
78
- it ( 'includes a validation error for _requiresAdditionalSupport_' , ( ) => {
79
- expect ( page . errors ( ) ) . toHaveProperty (
80
- 'requiresAdditionalSupport' ,
81
- 'Confirm whether additional support is required' ,
82
- )
65
+ describe ( 'and _supportDetail_ is UNANSWERED' , ( ) => {
66
+ it ( 'includes a validation error for _supportDetail_' , ( ) => {
67
+ expect ( page . errors ( ) ) . toHaveProperty ( 'supportDetail' , 'Enter the type of support needed' )
68
+ } )
69
+ } )
83
70
} )
84
- } )
85
71
86
- describe ( 'when _hasBrainInjury_ is YES' , ( ) => {
87
- const page = new BrainInjury ( { hasBrainInjury : 'yes' } , application )
72
+ describe ( 'when _receivingTreatment_ is YES' , ( ) => {
73
+ const page = new BrainInjury ( { receivingTreatment : 'yes' } , application )
88
74
89
- describe ( 'and _injuryDetail_ is UNANSWERED' , ( ) => {
90
- it ( 'includes a validation error for _injuryDetail_' , ( ) => {
91
- expect ( page . errors ( ) ) . toHaveProperty ( 'injuryDetail' , 'Describe their brain injury and needs' )
75
+ describe ( 'and _treatmentDetail_ is UNANSWERED' , ( ) => {
76
+ it ( 'includes a validation error for _treatmentDetail_' , ( ) => {
77
+ expect ( page . errors ( ) ) . toHaveProperty (
78
+ 'treatmentDetail' ,
79
+ 'Enter details about their treatment and medication' ,
80
+ )
81
+ } )
92
82
} )
93
83
} )
94
- } )
95
84
96
- describe ( 'when _isVulnerable_ is YES' , ( ) => {
97
- const page = new BrainInjury ( { isVulnerable : 'yes' } , application )
85
+ describe ( 'when _isVulnerable_ is YES' , ( ) => {
86
+ const page = new BrainInjury ( { isVulnerable : 'yes' } , application )
98
87
99
- describe ( 'and _vulnerabilityDetail_ is UNANSWERED' , ( ) => {
100
- it ( 'includes a validation error for _vulnerabilityDetail_' , ( ) => {
101
- expect ( page . errors ( ) ) . toHaveProperty ( 'vulnerabilityDetail' , 'Describe their level of vulnerability' )
88
+ describe ( 'and _vulnerabilityDetail_ is UNANSWERED' , ( ) => {
89
+ it ( 'includes a validation error for _vulnerabilityDetail_' , ( ) => {
90
+ expect ( page . errors ( ) ) . toHaveProperty ( 'vulnerabilityDetail' , 'Enter how they are vulnerable' )
91
+ } )
102
92
} )
103
93
} )
104
- } )
105
94
106
- describe ( 'when _hasDifficultyInteracting_ is YES' , ( ) => {
107
- const page = new BrainInjury ( { hasDifficultyInteracting : 'yes' } , application )
95
+ describe ( 'when _hasDifficultyInteracting_ is YES' , ( ) => {
96
+ const page = new BrainInjury ( { hasDifficultyInteracting : 'yes' } , application )
108
97
109
- describe ( 'and _interactionDetail_ is UNANSWERED' , ( ) => {
110
- it ( 'includes a validation error for _interactionDetail_' , ( ) => {
111
- expect ( page . errors ( ) ) . toHaveProperty (
112
- 'interactionDetail' ,
113
- 'Describe their difficulties interacting with other people' ,
114
- )
98
+ describe ( 'and _interactionDetail_ is UNANSWERED' , ( ) => {
99
+ it ( 'includes a validation error for _interactionDetail_' , ( ) => {
100
+ expect ( page . errors ( ) ) . toHaveProperty ( 'interactionDetail' , 'Enter the type of difficulties they have' )
101
+ } )
115
102
} )
116
103
} )
117
104
} )
118
105
119
- describe ( 'when _requiresAdditionalSupport_ is YES' , ( ) => {
120
- const page = new BrainInjury ( { requiresAdditionalSupport : 'yes' } , application )
106
+ describe ( 'onSave' , ( ) => {
107
+ it ( 'removes brain injury data when the question is set to "no"' , ( ) => {
108
+ const body : Partial < BrainInjuryBody > = {
109
+ hasBrainInjury : 'no' ,
110
+ injuryDetail : 'Injury detail' ,
111
+ }
112
+
113
+ const page = new BrainInjury ( body , application )
114
+
115
+ page . onSave ( )
121
116
122
- describe ( 'and _addSupportDetail_ is UNANSWERED' , ( ) => {
123
- it ( 'includes a validation error for _addSupportDetail_' , ( ) => {
124
- expect ( page . errors ( ) ) . toHaveProperty ( 'addSupportDetail' , 'Describe the additional support required' )
117
+ expect ( page . body ) . toEqual ( {
118
+ hasBrainInjury : 'no' ,
125
119
} )
126
120
} )
127
- } )
128
- } )
129
121
130
- describe ( 'onSave' , ( ) => {
131
- it ( 'removes brain injury data when the question is set to "no"' , ( ) => {
132
- const body : Partial < BrainInjuryBody > = {
133
- hasBrainInjury : 'no' ,
134
- injuryDetail : 'Injury detail' ,
135
- }
122
+ it ( 'removes support data when the question is set to "no"' , ( ) => {
123
+ const body : Partial < BrainInjuryBody > = {
124
+ supportNeeded : 'no' ,
125
+ supportDetail : 'Support detail' ,
126
+ }
136
127
137
- const page = new BrainInjury ( body , application )
128
+ const page = new BrainInjury ( body , application )
138
129
139
- page . onSave ( )
130
+ page . onSave ( )
140
131
141
- expect ( page . body ) . toEqual ( {
142
- hasBrainInjury : 'no' ,
132
+ expect ( page . body ) . toEqual ( {
133
+ supportNeeded : 'no' ,
134
+ } )
143
135
} )
144
- } )
145
136
146
- it ( 'removes vulnerability data when the question is set to "no"' , ( ) => {
147
- const body : Partial < BrainInjuryBody > = {
148
- isVulnerable : 'no' ,
149
- vulnerabilityDetail : 'Vulnerability detail' ,
150
- }
137
+ it ( 'removes treatment data when the question is set to "no"' , ( ) => {
138
+ const body : Partial < BrainInjuryBody > = {
139
+ receivingTreatment : 'no' ,
140
+ treatmentDetail : 'Treatment detail' ,
141
+ }
151
142
152
- const page = new BrainInjury ( body , application )
143
+ const page = new BrainInjury ( body , application )
153
144
154
- page . onSave ( )
145
+ page . onSave ( )
155
146
156
- expect ( page . body ) . toEqual ( {
157
- isVulnerable : 'no' ,
147
+ expect ( page . body ) . toEqual ( {
148
+ receivingTreatment : 'no' ,
149
+ } )
158
150
} )
159
- } )
160
151
161
- it ( 'removes interaction difficulty data when the question is set to "no"' , ( ) => {
162
- const body : Partial < BrainInjuryBody > = {
163
- hasDifficultyInteracting : 'no' ,
164
- interactionDetail : 'Interaction detail' ,
165
- }
152
+ it ( 'removes vulnerability data when the question is set to "no"' , ( ) => {
153
+ const body : Partial < BrainInjuryBody > = {
154
+ isVulnerable : 'no' ,
155
+ vulnerabilityDetail : 'Vulnerability detail' ,
156
+ }
166
157
167
- const page = new BrainInjury ( body , application )
158
+ const page = new BrainInjury ( body , application )
168
159
169
- page . onSave ( )
160
+ page . onSave ( )
170
161
171
- expect ( page . body ) . toEqual ( {
172
- hasDifficultyInteracting : 'no' ,
162
+ expect ( page . body ) . toEqual ( {
163
+ isVulnerable : 'no' ,
164
+ } )
173
165
} )
174
- } )
175
166
176
- it ( 'removes additional support data when the question is set to "no"' , ( ) => {
177
- const body : Partial < BrainInjuryBody > = {
178
- requiresAdditionalSupport : 'no' ,
179
- addSupportDetail : 'Additional support detail' ,
180
- }
167
+ it ( 'removes interaction difficulty data when the question is set to "no"' , ( ) => {
168
+ const body : Partial < BrainInjuryBody > = {
169
+ hasDifficultyInteracting : 'no' ,
170
+ interactionDetail : 'Interaction detail' ,
171
+ }
181
172
182
- const page = new BrainInjury ( body , application )
173
+ const page = new BrainInjury ( body , application )
183
174
184
- page . onSave ( )
175
+ page . onSave ( )
185
176
186
- expect ( page . body ) . toEqual ( {
187
- requiresAdditionalSupport : 'no' ,
177
+ expect ( page . body ) . toEqual ( {
178
+ hasDifficultyInteracting : 'no' ,
179
+ } )
188
180
} )
189
181
} )
190
182
} )
0 commit comments