-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
place-order-mixin.test.js
55 lines (48 loc) · 1.94 KB
/
place-order-mixin.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
});
});
});