From 9fb76d361022b2e36d218aacf7ea60474554a7bb Mon Sep 17 00:00:00 2001 From: Christopher Rogers Date: Wed, 11 Dec 2024 15:52:16 -0800 Subject: [PATCH] Fixes Stripe 3-D Secure intent handler specs --- .../three-d-secure/strategy/stripe.test.js | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/unit/risk/three-d-secure/strategy/stripe.test.js b/test/unit/risk/three-d-secure/strategy/stripe.test.js index 44fc3113..a96d7d12 100644 --- a/test/unit/risk/three-d-secure/strategy/stripe.test.js +++ b/test/unit/risk/three-d-secure/strategy/stripe.test.js @@ -18,15 +18,11 @@ describe('StripeStrategy', function () { this.target = testBed().querySelector('#three-d-secure-container'); this.sandbox = sinon.createSandbox(); - this.paymentIntentResult = { + this.intentResult = { paymentIntent: { id: 'pi-test-id', test: 'result', consistingOf: 'arbitrary-values' } }; - this.setupIntentResult = { - setupIntent: { id: 'seti-test-id', test: 'result', consistingOf: 'arbitrary-values' } - }; this.stripe = { - handleNextAction: sinon.stub().resolves(this.paymentIntentResult), - confirmCardSetup: sinon.stub().resolves(this.setupIntentResult) + handleNextAction: sinon.stub().resolves(this.intentResult), }; window.Stripe = sinon.spy(publishableKey => this.stripe); }); @@ -83,7 +79,7 @@ describe('StripeStrategy', function () { }); it('emits done with the paymentIntent result', function (done) { - const { strategy, target, paymentIntentResult: { paymentIntent: { id } } } = this; + const { strategy, target, intentResult: { paymentIntent: { id } } } = this; strategy.on('done', result => { assert.deepEqual(result, { id }); done(); @@ -115,17 +111,20 @@ describe('StripeStrategy', function () { const { threeDSecure } = this; this.strategy = new StripeStrategy({ threeDSecure, actionToken: actionTokenSetupIntent }); this.strategy.whenReady(() => done()); + this.intentResult = { + setupIntent: { id: 'pi-test-id', test: 'result', consistingOf: 'arbitrary-values' } + }; }); it('instructs Stripe.js to handle the card action using the client secret', function () { const { strategy, target, stripe } = this; strategy.attach(target); - assert(stripe.confirmCardSetup.calledOnce); - assert(stripe.confirmCardSetup.calledWithExactly('seti-test-stripe-client-secret')); + assert(stripe.handleNextAction.calledOnce); + assert(stripe.handleNextAction.calledWithExactly({ clientSecret: 'seti-test-stripe-client-secret' })); }); it('emits done with the setupIntent result', function (done) { - const { strategy, target, setupIntentResult: { setupIntent: { id } } } = this; + const { strategy, target, intentResult: { setupIntent: { id } } } = this; strategy.on('done', result => { assert.deepEqual(result, { id }); done(); @@ -137,7 +136,7 @@ describe('StripeStrategy', function () { beforeEach(function () { const { strategy } = this; this.exampleResult = { error: { example: 'error', for: 'testing' } }; - strategy.stripe.confirmCardSetup = sinon.stub().resolves(this.exampleResult); + strategy.stripe.handleNextAction = sinon.stub().resolves(this.exampleResult); }); it('emits an error on threeDSecure', function (done) {