Skip to content

Commit

Permalink
Update unit tests in both integrations
Browse files Browse the repository at this point in the history
ADCRSET29I-8
  • Loading branch information
Tamara committed Feb 21, 2025
1 parent cd772ab commit c725d67
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ describe('create-session-with-splits::execute', () => {
expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount)

const setCustomFieldAction = response.actions.find(
(a) => a.action === 'setCustomField',
(a) =>
a.action === 'setCustomField' && a.name === 'createSessionResponse',
)
expect(setCustomFieldAction.name).to.equal('createSessionResponse')
expect(setCustomFieldAction.value).to.be.a('string')
expect(setCustomFieldAction.value).to.equal(
addInterfaceInteraction.fields.response,
Expand Down
20 changes: 16 additions & 4 deletions extension/test/unit/make-payment.handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ describe('make-payment::execute', () => {
JSON.parse(paymentSuccessResponse).pspReference,
)

const setMerchantReferenceCustomFieldAction = response.actions.find(
(a) => a.action === 'setCustomField' && a.name === 'merchantReference',
)
expect(setMerchantReferenceCustomFieldAction.value).to.equal(
makePaymentRequest.reference,
)

const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
)
Expand Down Expand Up @@ -263,11 +270,10 @@ describe('make-payment::execute', () => {
addInterfaceInteraction.fields.response,
)

const setMerchantReferenceCustomField = response.actions.find(
const setMerchantReferenceCustomFieldAction = response.actions.find(
(a) => a.action === 'setCustomField' && a.name === 'merchantReference',
)
// eslint-disable-next-line @stylistic/js/max-len
expect(setMerchantReferenceCustomField.value).to.equal(
expect(setMerchantReferenceCustomFieldAction.value).to.equal(
makePaymentRequest.reference,
) // no pspReference until submitting additional details in redirect flow
},
Expand Down Expand Up @@ -324,7 +330,6 @@ describe('make-payment::execute', () => {
const setMerchantReferenceCustomField = response.actions.find(
(a) => a.action === 'setCustomField' && a.name === 'merchantReference',
)
// eslint-disable-next-line @stylistic/js/max-len
expect(setMerchantReferenceCustomField.value).to.equal(
makePaymentRequest.reference,
) // no pspReference until submitting additional details in redirect flow
Expand Down Expand Up @@ -385,6 +390,13 @@ describe('make-payment::execute', () => {
JSON.parse(paymentRefusedResponse).pspReference,
)

const setMerchantReferenceCustomFieldAction = response.actions.find(
(a) => a.action === 'setCustomField' && a.name === 'merchantReference',
)
expect(setMerchantReferenceCustomFieldAction.value).to.equal(
makePaymentRequest.reference,
)

const addTransaction = response.actions.find(
(a) => a.action === 'addTransaction',
)
Expand Down
13 changes: 9 additions & 4 deletions extension/test/unit/submit-payment-details.handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ describe('submit-additional-payment-details::execute', () => {
)
expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount)

const setCustomFieldAction = response.actions.find(
(a) => a.action === 'setCustomField',
const setKeyAction = response.actions.find((a) => a.action === 'setKey')
expect(setKeyAction.key).to.equal(
JSON.parse(submitPaymentDetailsSuccessResponse).pspReference,
)
expect(setCustomFieldAction.name).to.equal(
c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE,

const setCustomFieldAction = response.actions.find(
(a) =>
a.action === 'setCustomField' &&
a.name ===
c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE,
)
expect(setCustomFieldAction.value).to.be.a('string')
const expectedCustomFieldValue = JSON.parse(
Expand Down

0 comments on commit c725d67

Please sign in to comment.