Skip to content

Commit

Permalink
[TEST] update mocha test for apple-pay fraud
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanderson1130 committed Feb 28, 2025
1 parent 51dac64 commit 4572a05
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions test/unit/apple-pay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import merge from 'lodash.merge';
import omit from 'lodash.omit';
import Emitter from 'component-emitter';
import Promise from 'promise';
import { initRecurly, nextTick } from './support/helpers';
import { initRecurly, nextTick, testBed} from './support/helpers';
import BraintreeLoader from '../../lib/util/braintree-loader';
import filterSupportedNetworks from '../../lib/recurly/apple-pay/util/filter-supported-networks';

Expand Down Expand Up @@ -1285,27 +1285,38 @@ function applePayTest (integrationType) {
}));
});

it('when kount is selected, pass the expected parameters to create the token', function (done) {
this.spyTokenRequest = this.sandbox.spy(this.recurly.request, 'post');
this.applePay.config.kount = true;
it('when kount is selected, pass the expected parameters to create the token', function (done) {
beforeEach(function () {
const recurly = this.recurly = initRecurly();
recurly.configure({
fraud: {
kount: {
dataCollector: true,
form: testBed().querySelector('#test-form')
}
}
});
this.recurly.fraud.profile = { processor: 'kount', sessionId: 'KOUNT_SESSION_ID', udf: {} };
});

this.spyTokenRequest = this.sandbox.spy(this.recurly.request, 'post');

this.applePay.session.onpaymentauthorized(clone(validAuthorizeEvent));
this.applePay.on('token', ensureDone(done, () => {
this.applePay.session.onpaymentauthorized(clone(validAuthorizeEvent));
this.applePay.on('token', ensureDone(done, () => {
const args = this.spyTokenRequest.getCall(0).args[0];
const expectedData = {
paymentData: 'valid-payment-data',
paymentMethod: 'valid-payment-method',
fraud: { processor: 'kount', sessionId: 'KOUNT_SESSION_ID', udf: {} },
...billingAddress,
};

if (this.applePay.config.kount) {
expectedData.kountSessionId = 'KOUNT_SESSION_ID';
expectedData.fraud = { processor: 'kount', sessionId: 'KOUNT_SESSION_ID', udf: {} };
}

assert.deepEqual(args.data, expectedData);
}));
});
}));
});

it('passes the non address parameters to create the token', function (done) {
this.spyTokenRequest = this.sandbox.spy(this.recurly.request, 'post');
Expand Down

0 comments on commit 4572a05

Please sign in to comment.