Skip to content

Commit

Permalink
Update end date prep for rtn req setup journey
Browse files Browse the repository at this point in the history
On discussing what was needed to help the return requirements setup journey it was agreed we don't care about the reason, we just need the date value.

So, rather than adding the result as is from `myLicence.$ends()` instead we should just add the resulting date to the session.
  • Loading branch information
Cruikshanks committed Jan 23, 2024
1 parent 8f77bd1 commit 3adb880
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ async function _createSession (data) {

function _data (licence, journey) {
const { id, licenceDocument, licenceRef, licenceVersions } = licence
const ends = licence.$ends()

return {
licence: {
id,
ends: licence.$ends(),
endDate: ends ? ends.date : null,
licenceRef,
licenceHolder: _licenceHolder(licenceDocument),
startDate: _startDate(licenceVersions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ describe('Initiate Return Requirement Session service', () => {
const { data } = result

expect(data.licence.id).to.equal(licence.id)
expect(data.licence.ends).to.equal({ date: new Date('2024-08-10'), priority: 3, reason: 'expired' })
expect(data.licence.licenceRef).to.equal(licence.licenceRef)
expect(data.licence.licenceHolder).to.equal('Licence Holder Ltd')
})
Expand All @@ -112,6 +111,14 @@ describe('Initiate Return Requirement Session service', () => {
expect(data.licence.startDate).to.equal(new Date('2022-05-01'))
})

it("creates a new session record containing the licence's end date", async () => {
const result = await InitiateReturnRequirementSessionService.go(licence.id, journey)

const { data } = result

expect(data.licence.endDate).to.equal(new Date('2024-08-10'))
})

it('creates a new session record containing the journey passed in', async () => {
const result = await InitiateReturnRequirementSessionService.go(licence.id, journey)

Expand Down Expand Up @@ -143,7 +150,6 @@ describe('Initiate Return Requirement Session service', () => {
const { data } = result

expect(data.licence.id).to.equal(licence.id)
expect(data.licence.ends).to.equal({ date: new Date('2024-08-10'), priority: 3, reason: 'expired' })
expect(data.licence.licenceRef).to.equal(licence.licenceRef)
expect(data.licence.licenceHolder).to.equal('Luce Holder')
})
Expand All @@ -156,6 +162,14 @@ describe('Initiate Return Requirement Session service', () => {
expect(data.licence.startDate).to.equal(new Date('2022-05-01'))
})

it("creates a new session record containing the licence's end date", async () => {
const result = await InitiateReturnRequirementSessionService.go(licence.id, journey)

const { data } = result

expect(data.licence.endDate).to.equal(new Date('2024-08-10'))
})

it('creates a new session record containing the journey passed in', async () => {
const result = await InitiateReturnRequirementSessionService.go(licence.id, journey)

Expand Down

0 comments on commit 3adb880

Please sign in to comment.