Skip to content

Commit 92f620f

Browse files
committed
Checkout agreements mixin tests
1 parent 70f5e38 commit 92f620f

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'squire'
8+
], function (Squire) {
9+
'use strict';
10+
11+
describe('Magento_CheckoutAgreements/js/model/place-order-mixin', function () {
12+
var injector = new Squire(),
13+
mocks = {
14+
'Magento_Checkout/js/action/place-order': jasmine.createSpy('placeOrderAction'),
15+
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner')
16+
},
17+
mixin,
18+
placeOrderAction;
19+
20+
beforeEach(function (done) {
21+
window.checkoutConfig = {
22+
checkoutAgreements: {
23+
isEnabled: true
24+
}
25+
};
26+
injector.mock(mocks);
27+
injector.require([
28+
'Magento_CheckoutAgreements/js/model/place-order-mixin',
29+
'Magento_Checkout/js/action/place-order'
30+
], function (Mixin, placeOrder) {
31+
mixin = Mixin;
32+
placeOrderAction = placeOrder;
33+
done();
34+
});
35+
});
36+
37+
describe('Magento_Checkout/js/action/place-order', function () {
38+
it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () {
39+
var messageContainer = jasmine.createSpy('messageContainer'),
40+
paymentData = {};
41+
mixin(placeOrderAction)(paymentData, messageContainer);
42+
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner'])
43+
.toHaveBeenCalledWith(paymentData);
44+
expect(mocks['Magento_Checkout/js/action/place-order'])
45+
.toHaveBeenCalledWith(paymentData, messageContainer);
46+
});
47+
});
48+
});
49+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'squire'
8+
], function (Squire) {
9+
'use strict';
10+
11+
describe('Magento_CheckoutAgreements/js/model/set-payment-information-mixin', function () {
12+
var injector = new Squire(),
13+
mocks = {
14+
'Magento_Checkout/js/action/set-payment-information': jasmine.createSpy('placeOrderAction'),
15+
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner')
16+
},
17+
mixin,
18+
placeOrderAction;
19+
20+
beforeEach(function (done) {
21+
window.checkoutConfig = {
22+
checkoutAgreements: {
23+
isEnabled: true
24+
}
25+
};
26+
injector.mock(mocks);
27+
injector.require([
28+
'Magento_CheckoutAgreements/js/model/set-payment-information-mixin',
29+
'Magento_Checkout/js/action/set-payment-information'
30+
], function (Mixin, setPaymentInformation) {
31+
mixin = Mixin;
32+
placeOrderAction = setPaymentInformation;
33+
done();
34+
});
35+
});
36+
37+
describe('Magento_Checkout/js/action/set-payment-information', function () {
38+
it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () {
39+
var messageContainer = jasmine.createSpy('messageContainer'),
40+
paymentData = {};
41+
mixin(placeOrderAction)(messageContainer, paymentData);
42+
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner'])
43+
.toHaveBeenCalledWith(paymentData);
44+
expect(mocks['Magento_Checkout/js/action/set-payment-information'])
45+
.toHaveBeenCalledWith(messageContainer, paymentData);
46+
});
47+
});
48+
});
49+
});

0 commit comments

Comments
 (0)