Skip to content

Commit 4653799

Browse files
committed
MAGETWO-67106: Unstable Automated test Magento\Paypal\Test\TestCase\InContextExpressCheckoutFromShoppingCartTest failed on variation InContextExpressCheckoutFromShoppingCartTestVariation1
1 parent 7415c7e commit 4653799

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,48 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/* eslint-disable max-nested-callbacks */
67
define([
7-
'jquery',
8-
'Magento_Paypal/js/in-context/express-checkout'
9-
], function ($, ExpressCheckout) {
8+
'squire',
9+
'jquery'
10+
], function (Squire, $) {
1011
'use strict';
1112

1213
describe('Magento_Paypal/js/in-context/express-checkout', function () {
1314

14-
var model, event;
15+
var model,
16+
event,
17+
paypalExpressCheckout,
18+
injector = new Squire(),
19+
mocks = {
20+
'paypalInContextExpressCheckout': {
21+
checkout: jasmine.createSpyObj('checkout',
22+
['setup', 'initXO', 'startFlow', 'closeFlow']
23+
)
24+
}
25+
};
1526

1627
/**
1728
* Run before each test method
1829
*
1930
* @return void
2031
*/
2132
beforeEach(function (done) {
22-
model = new ExpressCheckout();
23-
2433
event = {
2534
/** Stub */
26-
preventDefault: function () {}
35+
preventDefault: jasmine.createSpy('preventDefault')
2736
};
2837

29-
done();
38+
injector.mock(mocks);
39+
40+
injector.require([
41+
'paypalInContextExpressCheckout',
42+
'Magento_Paypal/js/in-context/express-checkout'], function (PayPal, Constr) {
43+
paypalExpressCheckout = PayPal;
44+
model = new Constr();
45+
46+
done();
47+
});
3048
});
3149

3250
describe('clientConfig.click method', function () {
@@ -48,23 +66,26 @@ define([
4866

4967
it('Check call "click" method', function () {
5068

51-
$.ajax = jasmine.createSpy().and.callFake(function () {
69+
spyOn(jQuery.fn, 'trigger');
70+
spyOn(jQuery, 'get').and.callFake(function () {
5271
var d = $.Deferred();
5372

5473
d.resolve({
55-
'success': true
74+
'url': true
5675
});
5776

5877
return d.promise();
5978
});
6079

61-
$.fn.trigger = jasmine.createSpy();
62-
6380
model.clientConfig.click(event);
6481

65-
expect($.ajax).toHaveBeenCalled();
66-
expect($('body').trigger).toHaveBeenCalledWith('processStop');
82+
expect(event.preventDefault).toHaveBeenCalled();
83+
expect(paypalExpressCheckout.checkout.initXO).toHaveBeenCalled();
6784
expect(model.clientConfig.checkoutInited).toEqual(true);
85+
expect(jQuery.get).toHaveBeenCalled();
86+
expect(jQuery('body').trigger).toHaveBeenCalledWith(
87+
jasmine.arrayContaining(['processStart'], ['processStop'])
88+
);
6889
});
6990
});
7091
});

0 commit comments

Comments
 (0)