Skip to content

Commit

Permalink
Add test around braintree preflight
Browse files Browse the repository at this point in the history
  • Loading branch information
gilv93 committed Nov 5, 2024
1 parent 727607e commit e5037d7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/unit/risk/three-d-secure/strategy/braintree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,45 @@ describe('BraintreeStrategy', function () {
});
});
});

describe('preflight', function () {
beforeEach(function () {
const { recurly } = this;
this.number = '4111111111111111';
this.month = '01';
this.year = '2023';
this.cvv = '737'
recurly.config.risk.threeDSecure.proactive = {
enabled: true,
gatewayCode: 'test-gateway-code',
amount: 50,
currency: 'USD'
};
recurly.request.post = sinon.stub().resolves({
paymentMethodNonce: 'test-braintree-nonce',
clientToken: '1234',
bin: '411111',
});
});

it('sends the correct data', function (done) {
const { recurly, number, month, year, cvv } = this;

BraintreeStrategy.preflight({ recurly, number, month, year, cvv }).then(() => {
sinon.assert.calledWithMatch(recurly.request.post, {
route: '/risk/authentications',
data: {
gateway_type: BraintreeStrategy.strategyName,
gateway_code: 'test-gateway-code',
currency: 'USD',
number,
month,
year,
cvv
}
});
done();
});
});
});
});

0 comments on commit e5037d7

Please sign in to comment.