Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
CS-5553
  • Loading branch information
Tamara committed Jul 4, 2024
1 parent 9169de8 commit cd145c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
12 changes: 3 additions & 9 deletions extension/test/unit/make-payment.handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ describe('make-payment::execute', () => {
)

const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(paymentSuccessResponse).pspReference,
)
expect(setKeyAction.key).to.equal(makePaymentRequest.reference)

const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
Expand Down Expand Up @@ -372,9 +370,7 @@ describe('make-payment::execute', () => {
)

const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(paymentRefusedResponse).pspReference,
)
expect(setKeyAction.key).to.equal(makePaymentRequest.reference)

const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
Expand Down Expand Up @@ -438,9 +434,7 @@ describe('make-payment::execute', () => {
)

const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(paymentErrorResponse).pspReference,
)
expect(setKeyAction.key).to.equal(makePaymentRequest.reference)

const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
Expand Down
24 changes: 4 additions & 20 deletions extension/test/unit/submit-payment-details.handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('submit-additional-payment-details::execute', () => {

const response = await execute(ctpPaymentClone)

expect(response.actions).to.have.lengthOf(4)
expect(response.actions).to.have.lengthOf(3)
const addInterfaceInteraction = response.actions.find(
(a) => a.action === 'addInterfaceInteraction',
)
Expand Down Expand Up @@ -115,10 +115,6 @@ describe('submit-additional-payment-details::execute', () => {
expect(addTransaction.transaction.interactionId).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
},
)

Expand Down Expand Up @@ -278,7 +274,7 @@ describe('submit-additional-payment-details::execute', () => {

const response = await execute(ctpPaymentClone)

expect(response.actions).to.have.lengthOf(4)
expect(response.actions).to.have.lengthOf(3)
const addInterfaceInteractionAction = response.actions.find(
(a) => a.action === 'addInterfaceInteraction',
)
Expand All @@ -289,10 +285,6 @@ describe('submit-additional-payment-details::execute', () => {
(a) => a.action === 'setCustomField',
)
expect(setCustomFieldAction.value).to.include('additionalData')
const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
sandbox.restore()
},
)
Expand Down Expand Up @@ -327,7 +319,7 @@ describe('submit-additional-payment-details::execute', () => {

const response = await execute(ctpPaymentClone)

expect(response.actions).to.have.lengthOf(4)
expect(response.actions).to.have.lengthOf(3)
const addInterfaceInteractionAction = response.actions.find(
(a) => a.action === 'addInterfaceInteraction',
)
Expand All @@ -338,10 +330,6 @@ describe('submit-additional-payment-details::execute', () => {
(a) => a.action === 'setCustomField',
)
expect(setCustomFieldAction.value).to.not.include('additionalData')
const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
sandbox.restore()
},
)
Expand Down Expand Up @@ -376,15 +364,11 @@ describe('submit-additional-payment-details::execute', () => {

const response = await execute(ctpPaymentClone)

expect(response.actions).to.have.lengthOf(3)
expect(response.actions).to.have.lengthOf(2)
const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
)
expect(addTransaction).to.be.undefined
const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
},
)
})

0 comments on commit cd145c5

Please sign in to comment.