-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-84639: Correctly set payment information when using paypal #1…
- Loading branch information
Showing
6 changed files
with
158 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ine/tests/app/code/Magento/CheckoutAgreements/frontend/js/model/place-order-mixin.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'squire' | ||
], function (Squire) { | ||
'use strict'; | ||
|
||
var injector = new Squire(), | ||
mocks = { | ||
'Magento_Checkout/js/action/place-order': jasmine.createSpy('placeOrderAction'), | ||
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner') | ||
}, | ||
defaultContext = require.s.contexts._, | ||
mixin, | ||
placeOrderAction; | ||
|
||
beforeEach(function (done) { | ||
window.checkoutConfig = { | ||
checkoutAgreements: { | ||
isEnabled: true | ||
} | ||
}; | ||
injector.mock(mocks); | ||
injector.require([ | ||
'Magento_CheckoutAgreements/js/model/place-order-mixin', | ||
'Magento_Checkout/js/action/place-order' | ||
], function (Mixin, placeOrder) { | ||
mixin = Mixin; | ||
placeOrderAction = placeOrder; | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('Magento_CheckoutAgreements/js/model/place-order-mixin', function () { | ||
it('mixin is applied to Magento_Checkout/js/action/place-order', function () { | ||
var placeOrderMixins = defaultContext.config.config.mixins['Magento_Checkout/js/action/place-order']; | ||
|
||
expect(placeOrderMixins['Magento_CheckoutAgreements/js/model/place-order-mixin']).toBe(true); | ||
}); | ||
|
||
it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () { | ||
var messageContainer = jasmine.createSpy('messageContainer'), | ||
paymentData = {}; | ||
|
||
mixin(placeOrderAction)(paymentData, messageContainer); | ||
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner']) | ||
.toHaveBeenCalledWith(paymentData); | ||
expect(mocks['Magento_Checkout/js/action/place-order']) | ||
.toHaveBeenCalledWith(paymentData, messageContainer); | ||
}); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
...p/code/Magento/CheckoutAgreements/frontend/js/model/set-payment-information-mixin.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'squire' | ||
], function (Squire) { | ||
'use strict'; | ||
|
||
var injector = new Squire(), | ||
mocks = { | ||
'Magento_Checkout/js/action/set-payment-information': jasmine.createSpy('placeOrderAction'), | ||
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner') | ||
}, | ||
defaultContext = require.s.contexts._, | ||
mixin, | ||
placeOrderAction; | ||
|
||
beforeEach(function (done) { | ||
window.checkoutConfig = { | ||
checkoutAgreements: { | ||
isEnabled: true | ||
} | ||
}; | ||
injector.mock(mocks); | ||
injector.require([ | ||
'Magento_CheckoutAgreements/js/model/set-payment-information-mixin', | ||
'Magento_Checkout/js/action/set-payment-information' | ||
], function (Mixin, setPaymentInformation) { | ||
mixin = Mixin; | ||
placeOrderAction = setPaymentInformation; | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('Magento_CheckoutAgreements/js/model/set-payment-information-mixin', function () { | ||
it('mixin is applied to Magento_Checkout/js/action/set-payment-information', function () { | ||
var placeOrderMixins = defaultContext | ||
.config.config.mixins['Magento_Checkout/js/action/set-payment-information']; | ||
|
||
expect(placeOrderMixins['Magento_CheckoutAgreements/js/model/set-payment-information-mixin']).toBe(true); | ||
}); | ||
|
||
it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () { | ||
var messageContainer = jasmine.createSpy('messageContainer'), | ||
paymentData = {}; | ||
|
||
mixin(placeOrderAction)(messageContainer, paymentData); | ||
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner']) | ||
.toHaveBeenCalledWith(paymentData); | ||
expect(mocks['Magento_Checkout/js/action/set-payment-information']) | ||
.toHaveBeenCalledWith(messageContainer, paymentData); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters