Skip to content

Commit

Permalink
fix: test needs session in the url
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangoulding committed Dec 17, 2024
1 parent f4d2b95 commit 8edbea6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/controllers/notifications-setup.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { init } = require('../../app/server.js')

describe('Notifications Setup controller', () => {
const basePath = '/notifications/setup'
const session = { id: 'e0c77b74-7326-493d-be5e-0d1ad41594b5', data: {} }

let getOptions
let postOptions
Expand All @@ -45,8 +46,6 @@ describe('Notifications Setup controller', () => {

describe('notifications/setup', () => {
describe('GET', () => {
const session = { id: 'e0c77b74-7326-493d-be5e-0d1ad41594b5', data: {} }

beforeEach(async () => {
getOptions = {
method: 'GET',
Expand Down Expand Up @@ -78,7 +77,7 @@ describe('Notifications Setup controller', () => {
beforeEach(async () => {
getOptions = {
method: 'GET',
url: basePath + '/returns-period',
url: basePath + `/${session.id}/returns-period`,
auth: {
strategy: 'session',
credentials: { scope: ['returns'] }
Expand All @@ -87,6 +86,7 @@ describe('Notifications Setup controller', () => {
})
describe('when a request is valid', () => {
beforeEach(async () => {
Sinon.stub(InitiateSessionService, 'go').resolves(session)
Sinon.stub(ReturnsPeriodService, 'go').returns(_viewReturnsPeriod())
})

Expand All @@ -106,11 +106,12 @@ describe('Notifications Setup controller', () => {
describe('when the request succeeds', () => {
describe('and the validation fails', () => {
beforeEach(async () => {
Sinon.stub(InitiateSessionService, 'go').resolves(session)
Sinon.stub(SubmitReturnsPeriodService, 'go').returns({
..._viewReturnsPeriod(),
error: 'Something went wrong'
})
postOptions = postRequestOptions(basePath + '/returns-period', {})
postOptions = postRequestOptions(basePath + `/${session.id}/returns-period`, {})
})

it('returns the page successfully with the error summary banner', async () => {
Expand All @@ -124,7 +125,7 @@ describe('Notifications Setup controller', () => {
describe('and the validation succeeds', () => {
beforeEach(async () => {
Sinon.stub(SubmitReturnsPeriodService, 'go').returns({ redirect: 'send-notice' })
postOptions = postRequestOptions(basePath + '/returns-period', {})
postOptions = postRequestOptions(basePath + `/${session.id}/returns-period`, {})
})

it('redirects the to the next page', async () => {
Expand Down

0 comments on commit 8edbea6

Please sign in to comment.