diff --git a/src/server/common/test-helpers/snapshot-page.js b/src/server/common/test-helpers/snapshot-page.js index fe6aa06..f9667ad 100644 --- a/src/server/common/test-helpers/snapshot-page.js +++ b/src/server/common/test-helpers/snapshot-page.js @@ -6,16 +6,14 @@ import { withCsrfProtection } from './csrf.js' /* global expect, it, beforeAll, afterAll, describe */ /** - * @param {string} describeMessage - * @param {string} shouldMessage - * @param {string} urlPath + * @param {{describes: string, it: string, pageUrl: string }} options */ -export const describePageSnapshot = ( - describeMessage, - shouldMessage, - urlPath -) => { - describe(describeMessage, () => { +export const describePageSnapshot = ({ + describes, + it: itDescription, + pageUrl +}) => { + describe(describes, () => { /** @type {Server} */ let server @@ -28,11 +26,11 @@ export const describePageSnapshot = ( await server.stop({ timeout: 0 }) }) - it(shouldMessage, async () => { + it(itDescription, async () => { const { payload } = await server.inject( withCsrfProtection({ method: 'GET', - url: urlPath + url: pageUrl }) ) diff --git a/src/server/cookies-policy/index.test.js b/src/server/cookies-policy/index.test.js index 1a7d387..5304d13 100644 --- a/src/server/cookies-policy/index.test.js +++ b/src/server/cookies-policy/index.test.js @@ -1,10 +1,10 @@ import { describePageSnapshot } from '../common/test-helpers/snapshot-page.js' -describePageSnapshot( - '#destinationSummaryController', - 'should render expected response and content', - '/cookies' -) +describePageSnapshot({ + describes: '#destinationSummaryController', + it: 'should render expected response and content', + pageUrl: '/cookies' +}) /** * @import { Server } from '@hapi/hapi' diff --git a/src/server/destination/destination-type/index.test.js b/src/server/destination/destination-type/index.test.js index 2ebbcfd..896df9e 100644 --- a/src/server/destination/destination-type/index.test.js +++ b/src/server/destination/destination-type/index.test.js @@ -86,11 +86,11 @@ describe('DestinationTypePage', () => { expect(plugin).toHaveProperty('register') }) - describePageSnapshot( - 'DestinationTypePage.content', - 'should render expected response and content', + describePageSnapshot({ + describes: 'DestinationTypePage.content', + it: 'should render expected response and content', pageUrl - ) + }) }) /** @import { PluginBase, PluginNameVersion, Server } from '@hapi/hapi' */ diff --git a/src/server/destination/general-licence/index.test.js b/src/server/destination/general-licence/index.test.js index 02733b5..9725528 100644 --- a/src/server/destination/general-licence/index.test.js +++ b/src/server/destination/general-licence/index.test.js @@ -43,8 +43,8 @@ describe('DestinationGeneralLicencePage', () => { }) }) -describePageSnapshot( - 'DestinationGeneralLicenceController', - 'should render the expected content', - page.urlPath -) +describePageSnapshot({ + describes: 'DestinationGeneralLicenceController', + it: 'should render the expected content', + pageUrl: page.urlPath +}) diff --git a/src/server/licence/receiveMethod/index.test.js b/src/server/licence/receiveMethod/index.test.js index b60e070..c32a696 100644 --- a/src/server/licence/receiveMethod/index.test.js +++ b/src/server/licence/receiveMethod/index.test.js @@ -73,11 +73,11 @@ describe('ReceiveMethodPage', () => { expect(plugin).toHaveProperty('register') }) - describePageSnapshot( - 'DestinationTypePage.content', - 'should render expected response and content', + describePageSnapshot({ + describes: 'DestinationTypePage.content', + it: 'should render expected response and content', pageUrl - ) + }) }) /** @import { PluginBase, PluginNameVersion, Server } from '@hapi/hapi' */ diff --git a/src/server/origin/origin-type/index.test.js b/src/server/origin/origin-type/index.test.js index 1e4cfc4..f374c64 100644 --- a/src/server/origin/origin-type/index.test.js +++ b/src/server/origin/origin-type/index.test.js @@ -75,9 +75,9 @@ describe('OriginTypePage', () => { expect(plugin).toHaveProperty('register') }) - describePageSnapshot( - 'OriginTypePage.content', - 'should render expected response and content', + describePageSnapshot({ + describes: 'OriginTypePage.content', + it: 'should render expected response and content', pageUrl - ) + }) })