@@ -18,6 +18,7 @@ describe('Notifications Setup - Review presenter', () => {
18
18
let pagination
19
19
let testInput
20
20
let testRecipients
21
+ let testDuplicateRecipients
21
22
22
23
beforeEach ( ( ) => {
23
24
page = 1
@@ -26,8 +27,12 @@ describe('Notifications Setup - Review presenter', () => {
26
27
}
27
28
28
29
testRecipients = RecipientsFixture . recipients ( )
30
+ // This data is used to ensure the recipients are grouped when they have the same licence ref / name.
31
+ // Ignore the fact that these would be considered duplicates elsewhere in the code
32
+ // (e.g. contact hash / address being identical)
33
+ testDuplicateRecipients = RecipientsFixture . duplicateRecipients ( )
29
34
30
- testInput = Object . values ( testRecipients ) . map ( ( recipient ) => {
35
+ testInput = [ ... Object . values ( testRecipients ) , ... Object . values ( testDuplicateRecipients ) ] . map ( ( recipient ) => {
31
36
return {
32
37
...recipient ,
33
38
// The determine recipients service will add the message_type relevant to the recipient
@@ -39,33 +44,28 @@ describe('Notifications Setup - Review presenter', () => {
39
44
} )
40
45
41
46
describe ( 'when provided with "recipients"' , ( ) => {
42
- it ( 'correctly presents the data' , ( ) => {
47
+ it ( 'correctly presents the data (in alphabetical order) ' , ( ) => {
43
48
const result = ReviewPresenter . go ( testInput , page , pagination )
44
49
45
50
expect ( result ) . to . equal ( {
46
51
defaultPageSize : 25 ,
47
52
pageTitle : 'Send returns invitations' ,
48
53
recipients : [
49
54
{
50
-
51
- licences : [ testRecipients . primaryUser . licence_refs ] ,
52
- method : 'Letter or email - Primary user '
55
+ contact : [ 'Mr H J Duplicate Licence holder' , '4' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR '] ,
56
+ licences : [ testDuplicateRecipients . duplicateLicenceHolder . licence_refs ] ,
57
+ method : 'Letter or email - Licence holder '
53
58
} ,
54
59
{
55
-
56
- licences : [ testRecipients . returnsAgent . licence_refs ] ,
57
- method : 'Letter or email - Returns agent '
60
+ contact : [ 'Mr H J Duplicate Returns to' , '4' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR '] ,
61
+ licences : [ testDuplicateRecipients . duplicateReturnsTo . licence_refs ] ,
62
+ method : 'Letter or email - Returns to '
58
63
} ,
59
64
{
60
65
contact : [ 'Mr H J Licence holder' , '1' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
61
66
licences : [ testRecipients . licenceHolder . licence_refs ] ,
62
67
method : 'Letter or email - Licence holder'
63
68
} ,
64
- {
65
- contact : [ 'Mr H J Returns to' , '2' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
66
- licences : [ testRecipients . returnsTo . licence_refs ] ,
67
- method : 'Letter or email - Returns to'
68
- } ,
69
69
{
70
70
contact : [
71
71
'Mr H J Licence holder with multiple licences' ,
@@ -77,9 +77,34 @@ describe('Notifications Setup - Review presenter', () => {
77
77
] ,
78
78
licences : testRecipients . licenceHolderWithMultipleLicences . licence_refs . split ( ',' ) ,
79
79
method : 'Letter or email - Licence holder'
80
+ } ,
81
+ {
82
+ contact : [ 'Mr H J Returns to' , '2' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
83
+ licences : [ testRecipients . returnsTo . licence_refs ] ,
84
+ method : 'Letter or email - Returns to'
85
+ } ,
86
+ {
87
+
88
+ licences : [ testRecipients . primaryUser . licence_refs ] ,
89
+ method : 'Letter or email - Primary user'
90
+ } ,
91
+ {
92
+
93
+ licences : [ testDuplicateRecipients . duplicatePrimaryUser . licence_refs ] ,
94
+ method : 'Letter or email - Primary user'
95
+ } ,
96
+ {
97
+
98
+ licences : [ testRecipients . returnsAgent . licence_refs ] ,
99
+ method : 'Letter or email - Returns agent'
100
+ } ,
101
+ {
102
+
103
+ licences : [ testDuplicateRecipients . duplicateReturnsAgent . licence_refs ] ,
104
+ method : 'Letter or email - Returns agent'
80
105
}
81
106
] ,
82
- recipientsAmount : 5
107
+ recipientsAmount : 9
83
108
} )
84
109
} )
85
110
@@ -90,25 +115,27 @@ describe('Notifications Setup - Review presenter', () => {
90
115
91
116
expect ( result . recipients ) . to . equal ( [
92
117
{
93
-
94
- licences : [ testRecipients . primaryUser . licence_refs ] ,
95
- method : 'Letter or email - Primary user'
118
+ contact : [
119
+ 'Mr H J Duplicate Licence holder' ,
120
+ '4' ,
121
+ 'Privet Drive' ,
122
+ 'Little Whinging' ,
123
+ 'Surrey' ,
124
+ 'WD25 7LR'
125
+ ] ,
126
+ licences : [ testDuplicateRecipients . duplicateLicenceHolder . licence_refs ] ,
127
+ method : 'Letter or email - Licence holder'
96
128
} ,
97
129
{
98
-
99
- licences : [ testRecipients . returnsAgent . licence_refs ] ,
100
- method : 'Letter or email - Returns agent '
130
+ contact : [ 'Mr H J Duplicate Returns to' , '4' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR '] ,
131
+ licences : [ testDuplicateRecipients . duplicateReturnsTo . licence_refs ] ,
132
+ method : 'Letter or email - Returns to '
101
133
} ,
102
134
{
103
135
contact : [ 'Mr H J Licence holder' , '1' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
104
136
licences : [ testRecipients . licenceHolder . licence_refs ] ,
105
137
method : 'Letter or email - Licence holder'
106
138
} ,
107
- {
108
- contact : [ 'Mr H J Returns to' , '2' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
109
- licences : [ testRecipients . returnsTo . licence_refs ] ,
110
- method : 'Letter or email - Returns to'
111
- } ,
112
139
{
113
140
contact : [
114
141
'Mr H J Licence holder with multiple licences' ,
@@ -120,6 +147,31 @@ describe('Notifications Setup - Review presenter', () => {
120
147
] ,
121
148
licences : testRecipients . licenceHolderWithMultipleLicences . licence_refs . split ( ',' ) ,
122
149
method : 'Letter or email - Licence holder'
150
+ } ,
151
+ {
152
+ contact : [ 'Mr H J Returns to' , '2' , 'Privet Drive' , 'Little Whinging' , 'Surrey' , 'WD25 7LR' ] ,
153
+ licences : [ testRecipients . returnsTo . licence_refs ] ,
154
+ method : 'Letter or email - Returns to'
155
+ } ,
156
+ {
157
+
158
+ licences : [ testRecipients . primaryUser . licence_refs ] ,
159
+ method : 'Letter or email - Primary user'
160
+ } ,
161
+ {
162
+
163
+ licences : [ testDuplicateRecipients . duplicatePrimaryUser . licence_refs ] ,
164
+ method : 'Letter or email - Primary user'
165
+ } ,
166
+ {
167
+
168
+ licences : [ testRecipients . returnsAgent . licence_refs ] ,
169
+ method : 'Letter or email - Returns agent'
170
+ } ,
171
+ {
172
+
173
+ licences : [ testDuplicateRecipients . duplicateReturnsAgent . licence_refs ] ,
174
+ method : 'Letter or email - Returns agent'
123
175
}
124
176
] )
125
177
} )
@@ -199,7 +251,7 @@ describe('Notifications Setup - Review presenter', () => {
199
251
200
252
describe ( 'and there are >= 25 recipients' , ( ) => {
201
253
beforeEach ( ( ) => {
202
- testInput = [ ...testInput , ...testInput , ...testInput , ... testInput , ... testInput , ... testInput ]
254
+ testInput = [ ...testInput , ...testInput , ...testInput ]
203
255
204
256
pagination = {
205
257
numberOfPages : 2
@@ -228,7 +280,7 @@ describe('Notifications Setup - Review presenter', () => {
228
280
it ( 'returns the remaining recipients' , ( ) => {
229
281
const result = ReviewPresenter . go ( testInput , page , pagination )
230
282
231
- expect ( result . recipients . length ) . to . equal ( 5 )
283
+ expect ( result . recipients . length ) . to . equal ( 2 )
232
284
} )
233
285
234
286
it ( 'returns the updated "pageTitle"' , ( ) => {
0 commit comments