-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FCRM-5495 added appType to the payload for requestProductFour
- Loading branch information
Showing
4 changed files
with
27 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ const { | |
submitPostRequest | ||
} = require('../../__test-helpers__/server') | ||
const { mockPolygons } = require('../../services/__tests__/__mocks__/floodZonesByPolygonMock') | ||
const { getCentreOfPolygon } = require('../../services/shape-utils') | ||
jest.mock('../../services/agol/getContacts') | ||
jest.mock('../../services/address') | ||
jest.mock('@hapi/wreck') | ||
|
@@ -25,6 +26,7 @@ describe('Check your details page', () => { | |
} | ||
}) | ||
}) | ||
|
||
describe('GET', () => { | ||
const floodZoneGets = [ | ||
{ polygon: mockPolygons.fz1_only, floodZone: '1' }, | ||
|
@@ -42,6 +44,7 @@ describe('Check your details page', () => { | |
}) | ||
}) | ||
}) | ||
|
||
describe('POST', () => { | ||
// Makes a first request with no cookie | ||
const postTests = [ | ||
|
@@ -91,10 +94,11 @@ describe('Check your details page', () => { | |
request.state = { p4Request: p4Cookie } | ||
return h.continue | ||
}) | ||
|
||
const { polygon } = payload | ||
const { x, y } = getCentreOfPolygon(polygon) | ||
const queryParams = { | ||
applicationReferenceNumber: expectedAppRef, | ||
polygon: payload.polygon, | ||
polygon, | ||
recipientemail: payload.recipientemail, | ||
zoneNumber: expectedZoneNumber | ||
} | ||
|
@@ -103,6 +107,24 @@ describe('Check your details page', () => { | |
expect(response.headers.location).toEqual(`/confirmation?${new URLSearchParams(queryParams).toString()}`) | ||
expect(response.request.state.p4Request).toEqual(p4Cookie) | ||
expect(wreck.post).toHaveBeenCalledTimes(expectedWreckCalls) | ||
if (expectedWreckCalls) { | ||
const expectedPayload = JSON.stringify({ | ||
appType: 'internal', | ||
name: user.fullName, | ||
recipientemail: user.email, | ||
x, | ||
y, | ||
polygon: `[${polygon}]`, | ||
zoneNumber: expectedZoneNumber, | ||
plotSize: '0', | ||
areaName: 'Yorkshire', | ||
psoEmailAddress: '[email protected]', | ||
llfa: 'North Yorkshire', | ||
postcode: 'M1 1AA' | ||
}) | ||
|
||
expect(wreck.post).toHaveBeenCalledWith('http://dummyuri/order-product-four', { json: true, payload: expectedPayload }) | ||
} | ||
}) | ||
}) | ||
// Sad paths | ||
|
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