-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
set-payment-information-mixin.test.js
56 lines (49 loc) · 2.07 KB
/
set-payment-information-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
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);
});
});
});