-
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 branch information
Showing
12 changed files
with
404 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,77 @@ | ||
'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 AdditionalSubmissionOptionsPresenter = require('../../../app/presenters/return-requirements/additional-submission-options.presenter.js') | ||
|
||
describe('Return Requirements - Additional Submission Options presenter', () => { | ||
let session | ||
|
||
beforeEach(() => { | ||
session = { | ||
id: '61e07498-f309-4829-96a9-72084a54996d', | ||
checkPageVisited: false, | ||
licence: { | ||
id: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', | ||
currentVersionStartDate: '2023-01-01T00:00:00.000Z', | ||
endDate: null, | ||
licenceRef: '01/ABC', | ||
licenceHolder: 'Turbo Kid', | ||
startDate: '2022-04-01T00:00:00.000Z' | ||
}, | ||
journey: 'returns-required', | ||
requirements: [{}], | ||
startDateOptions: 'licenceStartDate', | ||
reason: 'major-change' | ||
} | ||
}) | ||
|
||
describe('when provided with a session', () => { | ||
it('correctly presents the data without additional submission options', () => { | ||
const result = AdditionalSubmissionOptionsPresenter.go(session) | ||
|
||
expect(result).to.be.equal({ | ||
backLink: '/system/return-requirements/61e07498-f309-4829-96a9-72084a54996d/check', | ||
licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', | ||
additionalSubmissionOptions: '', | ||
licenceRef: '01/ABC' | ||
}) | ||
}) | ||
}) | ||
|
||
describe("the 'backLink' property", () => { | ||
it("returns a link back to the 'check' page", () => { | ||
const result = AdditionalSubmissionOptionsPresenter.go(session) | ||
|
||
expect(result.backLink).to.equal('/system/return-requirements/61e07498-f309-4829-96a9-72084a54996d/check') | ||
}) | ||
}) | ||
|
||
describe("the 'additionalSubmissionOptions' property", () => { | ||
describe('when the user has previously submitted additional submission options', () => { | ||
beforeEach(() => { | ||
session.additionalSubmissionOptions = ['multiple-upload'] | ||
}) | ||
|
||
it('returns the options', () => { | ||
const result = AdditionalSubmissionOptionsPresenter.go(session) | ||
|
||
expect(result.additionalSubmissionOptions).to.equal(['multiple-upload']) | ||
}) | ||
}) | ||
|
||
describe('when the user has not previously chosen options', () => { | ||
it('returns empty options', () => { | ||
const result = AdditionalSubmissionOptionsPresenter.go(session) | ||
|
||
expect(result.additionalSubmissionOptions).to.be.equal('') | ||
}) | ||
}) | ||
}) | ||
}) |
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
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,62 @@ | ||
'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 | ||
|
||
// Test helpers | ||
const DatabaseSupport = require('../../support/database.js') | ||
const SessionHelper = require('../../support/helpers/session.helper.js') | ||
|
||
// Thing under test | ||
const AdditionalSubmissionOptionsService = require('../../../app/services/return-requirements/additional-submission-options.service.js') | ||
|
||
describe('Return Requirements - Additional Submission Options service', () => { | ||
let session | ||
|
||
beforeEach(async () => { | ||
await DatabaseSupport.clean() | ||
|
||
session = await SessionHelper.add({ | ||
data: { | ||
checkPageVisited: false, | ||
licence: { | ||
id: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', | ||
currentVersionStartDate: '2023-01-01T00:00:00.000Z', | ||
endDate: null, | ||
licenceRef: '01/ABC', | ||
licenceHolder: 'Turbo Kid', | ||
startDate: '2022-04-01T00:00:00.000Z' | ||
}, | ||
journey: 'returns-required', | ||
requirements: [{}], | ||
startDateOptions: 'licenceStartDate', | ||
reason: 'major-change' | ||
} | ||
}) | ||
}) | ||
|
||
describe('when called', () => { | ||
it('fetches the current setup session record', async () => { | ||
const result = await AdditionalSubmissionOptionsService.go(session.id) | ||
|
||
expect(result.sessionId).to.equal(session.id) | ||
}) | ||
|
||
it('returns page data for the view', async () => { | ||
const result = await AdditionalSubmissionOptionsService.go(session.id) | ||
|
||
expect(result).to.equal({ | ||
activeNavBar: 'search', | ||
additionalSubmissionOptions: '', | ||
backLink: `/system/return-requirements/${session.id}/check`, | ||
licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', | ||
licenceRef: '01/ABC', | ||
pageTitle: 'Select any additional submission options for the return requirements' | ||
}, { skip: ['sessionId'] }) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.