Skip to content

Commit dd12fff

Browse files
committed
MAGETWO-67106: Unstable Automated test Magento\Paypal\Test\TestCase\InContextExpressCheckoutFromShoppingCartTest failed on variation InContextExpressCheckoutFromShoppingCartTestVariation1
1 parent 30f3ad7 commit dd12fff

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define(
2525
defaults: {
2626
clientConfig: {
2727

28-
inited: false,
28+
checkoutInited: false,
2929

3030
/**
3131
* @param {Object} event
@@ -35,9 +35,9 @@ define(
3535

3636
event.preventDefault();
3737

38-
if (!this.clientConfig.inited) {
38+
if (!this.clientConfig.checkoutInited) {
3939
paypalExpressCheckout.checkout.initXO();
40-
this.clientConfig.inited = true;
40+
this.clientConfig.checkoutInited = true;
4141
} else {
4242
paypalExpressCheckout.checkout.closeFlow();
4343
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'Magento_Paypal/js/in-context/express-checkout'
9+
], function ($, ExpressCheckout) {
10+
'use strict';
11+
12+
describe('Magento_Paypal/js/in-context/express-checkout', function () {
13+
14+
var model, event;
15+
16+
/**
17+
* Run before each test method
18+
*
19+
* @return void
20+
*/
21+
beforeEach(function (done) {
22+
model = new ExpressCheckout();
23+
24+
event = {
25+
/** Stub */
26+
preventDefault: function () {}
27+
};
28+
29+
done();
30+
});
31+
32+
describe('clientConfig.click method', function () {
33+
34+
it('Check for properties defined ', function () {
35+
expect(model.hasOwnProperty('clientConfig')).toBeDefined();
36+
expect(model.clientConfig.hasOwnProperty('click')).toBeDefined();
37+
expect(model.clientConfig.hasOwnProperty('checkoutInited')).toBeDefined();
38+
});
39+
40+
it('Check properties type', function () {
41+
expect(typeof model.clientConfig.checkoutInited).toEqual('boolean');
42+
expect(typeof model.clientConfig.click).toEqual('function');
43+
});
44+
45+
it('Check properties value', function () {
46+
expect(model.clientConfig.checkoutInited).toEqual(false);
47+
});
48+
49+
it('Check call "click" method', function () {
50+
51+
$.ajax = jasmine.createSpy().and.callFake(function () {
52+
var d = $.Deferred();
53+
54+
d.resolve({
55+
'success': true
56+
});
57+
58+
return d.promise();
59+
});
60+
61+
$.fn.trigger = jasmine.createSpy();
62+
63+
model.clientConfig.click(event);
64+
65+
expect($.ajax).toHaveBeenCalled();
66+
expect($('body').trigger).toHaveBeenCalledWith('processStop');
67+
expect(model.clientConfig.checkoutInited).toEqual(true);
68+
});
69+
});
70+
});
71+
});

0 commit comments

Comments
 (0)