Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks committed Aug 9, 2024
1 parent c056aeb commit bd1cdda
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test/services/licences/fetch-return-versions.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,39 @@ const FetchReturnVersionsService =
require('../../../app/services/licences/fetch-return-versions.service.js')

describe('Fetch Return Versions service', () => {
let returnVersion
const startDate = new Date('2022-04-01')

let currentReturnVersion
let supersededReturnVersion

describe('when the licence has return versions data', () => {
beforeEach(async () => {
returnVersion = await ReturnVersionHelper.add()
// NOTE: We add 2, both with the same start date to ensure the order that they are returned is as expected
currentReturnVersion = await ReturnVersionHelper.add({
startDate, status: 'superseded', version: 100
})
supersededReturnVersion = await ReturnVersionHelper.add({
licenceId: currentReturnVersion.licenceId, startDate, status: 'current', version: 101
})
})

it('returns the matching return versions data', async () => {
const result = await FetchReturnVersionsService.go(returnVersion.licenceId)
const result = await FetchReturnVersionsService.go(currentReturnVersion.licenceId)

expect(result).to.equal([
{
id: returnVersion.id,
id: currentReturnVersion.id,
startDate: new Date('2022-04-01'),
endDate: null,
status: 'current',
reason: 'new-licence'
},
{
id: supersededReturnVersion.id,
startDate: new Date('2022-04-01'),
endDate: null,
status: 'superseded',
reason: 'new-licence'
}
])
})
Expand Down

0 comments on commit bd1cdda

Please sign in to comment.