@@ -173,19 +173,23 @@ describe('View Return Log presenter', () => {
173
173
} )
174
174
175
175
describe ( 'when the return submission method is abstractionVolumes' , ( ) => {
176
- it ( 'returns false' , ( ) => {
176
+ beforeEach ( ( ) => {
177
177
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$method' ) . returns ( 'abstractionVolumes' )
178
+ } )
178
179
180
+ it ( 'returns false' , ( ) => {
179
181
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
180
182
181
183
expect ( result . displayReadings ) . to . equal ( false )
182
184
} )
183
185
} )
184
186
185
187
describe ( "when the return submission method isn't abstractionVolumes" , ( ) => {
186
- it ( 'returns true' , ( ) => {
188
+ beforeEach ( ( ) => {
187
189
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$method' ) . returns ( 'NOT_ABSTRACTION_VOLUMES' )
190
+ } )
188
191
192
+ it ( 'returns true' , ( ) => {
189
193
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
190
194
191
195
expect ( result . displayReadings ) . to . equal ( true )
@@ -203,25 +207,27 @@ describe('View Return Log presenter', () => {
203
207
} )
204
208
205
209
describe ( 'when there is a return submission' , ( ) => {
210
+ beforeEach ( ( ) => {
211
+ setupSubmission ( testReturnLog )
212
+ } )
213
+
206
214
describe ( 'which is a nil return' , ( ) => {
207
215
beforeEach ( ( ) => {
208
- setupSubmission ( testReturnLog )
216
+ testReturnLog . returnSubmissions [ 0 ] . nilReturn = true
209
217
} )
210
218
211
219
it ( 'returns false' , ( ) => {
212
- testReturnLog . returnSubmissions [ 0 ] . nilReturn = true
213
-
214
220
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
215
221
216
222
expect ( result . displayTable ) . to . equal ( false )
217
223
} )
224
+ } )
218
225
219
- describe ( 'which is not a nil return' , ( ) => {
220
- it ( 'returns true' , ( ) => {
221
- const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
226
+ describe ( 'which is not a nil return' , ( ) => {
227
+ it ( 'returns true' , ( ) => {
228
+ const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
222
229
223
- expect ( result . displayTable ) . to . equal ( true )
224
- } )
230
+ expect ( result . displayTable ) . to . equal ( true )
225
231
} )
226
232
} )
227
233
} )
@@ -255,19 +261,23 @@ describe('View Return Log presenter', () => {
255
261
} )
256
262
257
263
describe ( 'when the unit is not cubic metres' , ( ) => {
258
- it ( 'returns true' , ( ) => {
264
+ beforeEach ( ( ) => {
259
265
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$units' ) . returns ( unitNames . GALLONS )
266
+ } )
260
267
268
+ it ( 'returns true' , ( ) => {
261
269
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
262
270
263
271
expect ( result . displayUnits ) . to . equal ( true )
264
272
} )
265
273
} )
266
274
267
- describe ( 'when the unit is not cubic metres' , ( ) => {
268
- it ( 'returns false' , ( ) => {
275
+ describe ( 'when the unit is cubic metres' , ( ) => {
276
+ beforeEach ( ( ) => {
269
277
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$units' ) . returns ( unitNames . CUBIC_METRES )
278
+ } )
270
279
280
+ it ( 'returns false' , ( ) => {
271
281
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
272
282
273
283
expect ( result . displayUnits ) . to . equal ( false )
@@ -394,34 +404,46 @@ describe('View Return Log presenter', () => {
394
404
} )
395
405
396
406
describe ( 'the "purpose" property' , ( ) => {
397
- it ( 'returns the alias when the first purpose has an alias' , ( ) => {
398
- const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
407
+ describe ( 'when the first purpose has an alias' , ( ) => {
408
+ it ( 'returns the alias' , ( ) => {
409
+ const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
399
410
400
- expect ( result . purpose ) . to . equal ( 'PURPOSE_ALIAS' )
411
+ expect ( result . purpose ) . to . equal ( 'PURPOSE_ALIAS' )
412
+ } )
401
413
} )
402
414
403
- it ( 'returns the tertiary description when the first purpose has no alias ' , ( ) => {
404
- testReturnLog . purposes . unshift ( { tertiary : { description : 'TERTIARY_DESCRIPTION' } } )
415
+ describe ( 'when the first purpose has no alias' , ( ) => {
416
+ beforeEach ( ( ) => {
417
+ testReturnLog . purposes . unshift ( { tertiary : { description : 'TERTIARY_DESCRIPTION' } } )
418
+ } )
405
419
406
- const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
420
+ it ( 'returns the tertiary description' , ( ) => {
421
+ const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
407
422
408
- expect ( result . purpose ) . to . equal ( 'TERTIARY_DESCRIPTION' )
423
+ expect ( result . purpose ) . to . equal ( 'TERTIARY_DESCRIPTION' )
424
+ } )
409
425
} )
410
426
} )
411
427
412
428
describe ( 'the "receivedDate" property' , ( ) => {
413
- it ( 'returns the formatted date when a received date is present' , ( ) => {
414
- testReturnLog . receivedDate = new Date ( `2022-01-01` )
415
-
416
- const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
429
+ describe ( 'when no received date is present' , ( ) => {
430
+ it ( 'returns null ' , ( ) => {
431
+ const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
417
432
418
- expect ( result . receivedDate ) . to . equal ( '1 January 2022' )
433
+ expect ( result . receivedDate ) . to . be . null ( )
434
+ } )
419
435
} )
420
436
421
- it ( 'returns null when no received date is present' , ( ) => {
422
- const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
437
+ describe ( 'when a received date is present' , ( ) => {
438
+ beforeEach ( ( ) => {
439
+ testReturnLog . receivedDate = new Date ( `2022-01-01` )
440
+ } )
441
+
442
+ it ( 'returns the formatted date' , ( ) => {
443
+ const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
423
444
424
- expect ( result . receivedDate ) . to . be . null ( )
445
+ expect ( result . receivedDate ) . to . equal ( '1 January 2022' )
446
+ } )
425
447
} )
426
448
} )
427
449
@@ -508,19 +530,23 @@ describe('View Return Log presenter', () => {
508
530
} )
509
531
510
532
describe ( 'when the method is abstractionVolumes' , ( ) => {
511
- it ( "returns 'abstraction volumes' in the title" , ( ) => {
533
+ beforeEach ( ( ) => {
512
534
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$method' ) . returns ( 'abstractionVolumes' )
535
+ } )
513
536
537
+ it ( "returns 'abstraction volumes' in the title" , ( ) => {
514
538
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
515
539
516
540
expect ( result . tableTitle ) . to . contain ( 'abstraction volumes' )
517
541
} )
518
542
} )
519
543
520
544
describe ( 'when the method is not abstractionVolumes' , ( ) => {
521
- it ( "returns 'meter readings' in the title" , ( ) => {
545
+ beforeEach ( ( ) => {
522
546
Sinon . stub ( testReturnLog . returnSubmissions [ 0 ] , '$method' ) . returns ( 'NOT_ABSTRACTION_VOLUMES' )
547
+ } )
523
548
549
+ it ( "returns 'meter readings' in the title" , ( ) => {
524
550
const result = ViewReturnLogPresenter . go ( testReturnLog , auth )
525
551
526
552
expect ( result . tableTitle ) . to . contain ( 'meter readings' )
0 commit comments