Skip to content

Commit 5dff040

Browse files
committed
MC-39820: Not be displayed Payment Method in Check Out with Multiple Addresses
1 parent 6ec2f1c commit 5dff040

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define(['squire', 'jquery'], function (Squire, $) {
7+
'use strict';
8+
9+
var injector = new Squire(),
10+
dataPost = {
11+
postData: jasmine.createSpy()
12+
},
13+
mocks = {
14+
/** Stub */
15+
'mage/dataPost': function () {
16+
return dataPost;
17+
}
18+
},
19+
checkbox,
20+
url = 'example.com',
21+
22+
/**
23+
* Toggle checkbox and assert that event was triggered.
24+
*
25+
* @param {Integer} value
26+
*/
27+
toggleCheckbox = function (value) {
28+
checkbox.trigger('click');
29+
expect(dataPost.postData.calls.mostRecent().args[0]).toEqual({
30+
action: url,
31+
data: {
32+
useBalance: value
33+
}
34+
});
35+
};
36+
37+
beforeEach(function (done) {
38+
checkbox = $('<input type="checkbox" name="use_balance" checked="checked"/>');
39+
$(document.body).append(checkbox);
40+
41+
injector.mock(mocks);
42+
injector.require(['multiShippingBalance'], function (balance) {
43+
balance({
44+
changeUrl: url
45+
}, checkbox);
46+
done();
47+
});
48+
});
49+
50+
afterEach(function () {
51+
try {
52+
injector.clean();
53+
injector.remove();
54+
} catch (e) {}
55+
56+
checkbox.remove();
57+
});
58+
59+
describe('multiShippingBalance', function () {
60+
it('Check actions after clicking on checkbox.', function () {
61+
toggleCheckbox(0);
62+
toggleCheckbox(1);
63+
toggleCheckbox(0);
64+
expect(dataPost.postData).toHaveBeenCalledTimes(3);
65+
});
66+
});
67+
});

0 commit comments

Comments
 (0)