-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add: Presenter test
1 parent
3be9290
commit 5ef8f29
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
test/presenters/return-logs/setup/single-volume.presenter.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
'use strict' | ||
|
||
// Test framework dependencies | ||
const Lab = require('@hapi/lab') | ||
const Code = require('@hapi/code') | ||
|
||
const { describe, it, beforeEach } = (exports.lab = Lab.script()) | ||
const { expect } = Code | ||
|
||
// Thing under test | ||
const SingleVolumePresenter = require('../../../../app/presenters/return-logs/setup/single-volume.presenter.js') | ||
|
||
describe('Return Logs Setup - Single Volume presenter', () => { | ||
let session | ||
|
||
beforeEach(() => { | ||
session = { | ||
id: '61e07498-f309-4829-96a9-72084a54996d', | ||
returnReference: '012345', | ||
units: 'litres' | ||
} | ||
}) | ||
|
||
describe('when provided with a session', () => { | ||
it('correctly presents the data', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result).to.equal({ | ||
backLink: '/system/return-logs/setup/61e07498-f309-4829-96a9-72084a54996d/meter-provided', | ||
pageTitle: 'Is it a single volume?', | ||
returnReference: '012345', | ||
sessionId: '61e07498-f309-4829-96a9-72084a54996d', | ||
singleVolume: null, | ||
singleVolumeQuantity: null, | ||
units: 'litres' | ||
}) | ||
}) | ||
}) | ||
|
||
describe('the "singleVolume" property', () => { | ||
describe('when the user has previously selected "yes" to a single volume being provided', () => { | ||
beforeEach(() => { | ||
session.singleVolume = 'yes' | ||
}) | ||
|
||
it('returns the "singleVolume" property populated to re-select the option', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result.singleVolume).to.equal('yes') | ||
}) | ||
}) | ||
|
||
describe('when the user has previously selected "no" to a single volume being provided', () => { | ||
beforeEach(() => { | ||
session.singleVolume = 'no' | ||
}) | ||
|
||
it('returns the "singleVolume" property populated to re-select the option', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result.singleVolume).to.equal('no') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('the "singleVolumeQuantity" property', () => { | ||
describe('when the user has previously entered a "singleVolumeQuantity"', () => { | ||
beforeEach(() => { | ||
session.singleVolumeQuantity = '1000' | ||
}) | ||
|
||
it('returns the "singleVolumeQuantity" property populated to re-select the option', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result.singleVolumeQuantity).to.equal('1000') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('the "units" property', () => { | ||
describe('when the "units" property is "cubic-meters"', () => { | ||
beforeEach(() => { | ||
session.units = 'cubic-meters' | ||
}) | ||
|
||
it('returns the "units" property presenter correctly', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result.units).to.equal('cubic meters') | ||
}) | ||
}) | ||
|
||
describe('when the "units" property is "litres"', () => { | ||
beforeEach(() => { | ||
session.units = 'litres' | ||
}) | ||
|
||
it('returns the "units" property presenter correctly', () => { | ||
const result = SingleVolumePresenter.go(session) | ||
|
||
expect(result.units).to.equal('litres') | ||
}) | ||
}) | ||
}) | ||
}) |