diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 02cb319d..acbe9c3d 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1757,6 +1757,63 @@ describe('Store', () => { }) })); }); + it('only "Yes" endorsement answers are added to payload', () => { + // Arrange + const accountNumber = getRandomString(6, 6); + const currentDeductible = getRandomInt(0, 5000); + const noCoverage = getRandomBoolean(); + const endorsementAnswers = [ + { + questionNum: getRandomInt(1, 10), + endorsementName: getRandomString(8, 20), + questionText: getRandomString(50, 100), + selectedAnswer: 'Yes' + }, + { + questionNum: getRandomInt(1, 10), + endorsementName: getRandomString(8, 20), + questionText: getRandomString(50, 100), + selectedAnswer: 'Yes' + }, + { + questionNum: getRandomInt(1, 10), + endorsementName: getRandomString(8, 20), + questionText: getRandomString(50, 100), + selectedAnswer: 'No' + } + ]; + const policy = { + status: 'Active', // need to change this + policyState: getRandomString(2, 2) + }; + store.issConfig.parentAccountNumber = accountNumber; + store.order.currentDeductible = currentDeductible; + store.order.policy.noCoverage = noCoverage; + store.order.policy.status = policy.status; + store.order.vehicle.registration.state = policy.policyState; + store.order.policy.endorsementQuestionAnswers = endorsementAnswers; + globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({})); + + // Act + store.getFinalDeductible(); + + // Assert + const expected = [endorsementAnswers[0].endorsementName, endorsementAnswers[1].endorsementName]; + expect(globalMethods.callHttpClient).toHaveBeenCalledWith(({ + method: endpoints.FinalDeductible.method, + endpoint: endpoints.FinalDeductible.url, + payload: ({ + accountNumber, + currentDeductible, + noCoverage, + endorsements: expected, + policy: { + status: policy.status, + policyState: policy.policyState + } + }) + })); + }); }); describe('unsuccessful api call', () => { it('api call throws exception', async () => {