Skip to content

Commit a706ccd

Browse files
committed
AC-2558: Upgraded grunt-contrib-jasmine to the latest version
1 parent 07d15f8 commit a706ccd

File tree

19 files changed

+84
-44
lines changed

19 files changed

+84
-44
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/redirect-on-success.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ define(
2222
*/
2323
execute: function () {
2424
fullScreenLoader.startLoader();
25+
this.reloadPage();
26+
},
27+
28+
/**
29+
* Method to reload page
30+
*/
31+
reloadPage: function () {
2532
window.location.replace(url.build(this.redirectUrl));
2633
}
2734
};

app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
messageContainer = messageContainer || globalMessageList;
2525

2626
if (response.status == 401) { //eslint-disable-line eqeqeq
27-
window.location.replace(url.build('customer/account/login/'));
27+
this.reloadPage(url.build('customer/account/login/'));
2828
} else {
2929
try {
3030
error = JSON.parse(response.responseText);
@@ -35,6 +35,13 @@ define([
3535
}
3636
messageContainer.addErrorMessage(error);
3737
}
38+
},
39+
40+
/**
41+
* Method to reload page
42+
*/
43+
reloadPage: function (redirectUrl) {
44+
window.location.replace(redirectUrl);
3845
}
3946
};
4047
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
(function() {
7+
var env = jasmine.getEnv(),
8+
config = {random: false};
9+
10+
env.configure(config);
11+
})();

dev/tests/js/jasmine/spec_runner/tasks/jasmine.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ function init(config) {
6767
/**
6868
* @todo rename "helpers" to "specs" (implies overriding grunt-contrib-jasmine code)
6969
*/
70-
helpers: specs
70+
helpers: specs,
71+
sandboxArgs: {
72+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
73+
defaultViewport: {width: 400, height: 400, hasTouch: true},
74+
slowMo: 10000
75+
}
7176
}
7277
};
7378
});

dev/tests/js/jasmine/spec_runner/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</script>
2121
<% }); %>
2222
<% with (scripts) { %>
23-
<% [].concat(polyfills, jasmine, boot, vendor, src, reporters).forEach(function (script) { %>
23+
<% [].concat(polyfills, jasmine, '.grunt/grunt-contrib-jasmine/boot0.js', 'dev/tests/js/jasmine/spec_runner/jasmine-config.js', '.grunt/grunt-contrib-jasmine/boot1.js', vendor, src, reporters).forEach(function (script) { %>
2424
<script type="text/javascript" src="<%= script %>"></script>
2525
<% }); %>
2626
<% } %>

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/redirect-on-success.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ define([
3535
});
3636

3737
it('Checks if loader is called before redirect to success page.', function () {
38-
spyOn(window.location, 'replace').and.returnValue(false);
39-
38+
spyOn(RedirectOnSuccess, 'reloadPage').and.callFake(function () {});
4039
RedirectOnSuccess.execute();
4140

4241
expect(FullScreenLoader.startLoader).toHaveBeenCalled();

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ define([
6262
it('check on failed status', function () {
6363
var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']);
6464

65-
spyOn(window.location, 'replace').and.callFake(function () {});
65+
spyOn(model, 'reloadPage').and.callFake(function () {});
6666
model.process({
6767
status: 401,
6868
responseText: ''

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ define([
2525
});
2626

2727
it('Check on empty object.', function () {
28-
var expected = {
29-
countryId: 'US',
30-
regionCode: null,
31-
region: null
32-
};
28+
var result = newCustomerAddress({}),
29+
expected = {
30+
countryId: 'US',
31+
regionCode: null,
32+
region: null
33+
};
3334

34-
expect(JSON.stringify(newCustomerAddress({}))).toEqual(JSON.stringify(expected));
35+
result.postcode = undefined;
36+
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
3537
});
3638

3739
it('Check on function call with empty address data.', function () {
@@ -57,6 +59,7 @@ define([
5759
regionId: 1
5860
};
5961

62+
result.postcode = undefined;
6063
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
6164
});
6265
it('Check on regionId with countryId in address data.', function () {
@@ -69,6 +72,7 @@ define([
6972
region: null
7073
};
7174

75+
result.postcode = undefined;
7276
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
7377
});
7478
it('Check that extensionAttributes property exists if defined', function () {
@@ -86,6 +90,7 @@ define([
8690
}
8791
};
8892

93+
result.postcode = undefined;
8994
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
9095
});
9196
});

dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/qty-configurable.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ define(['squire'], function (Squire) {
4242
it('Product is not configurable by default', function () {
4343
var component = new Component(params);
4444

45-
expect(component.disabled()).toBeFalsy();
45+
expect(component.disabled()).toBeFalse();
4646
expect(component.value()).toEqual(1000);
4747
});
4848

4949
it('State of component does not changed', function () {
5050
var component = new Component(params);
5151

52-
expect(component.disabled()).toBeFalsy();
52+
expect(component.disabled()).toBeFalse();
5353

5454
component.value(99);
5555
component.handleQtyValue(false);
5656

57-
expect(component.disabled()).toBeFalsy();
57+
expect(component.disabled()).toBeFalse();
5858
expect(component.value()).toEqual(99);
5959
});
6060

6161
it('Product changed to configurable', function () {
6262
var component = new Component(params);
6363

64-
expect(component.disabled()).toBeFalsy();
64+
expect(component.disabled()).toBeFalse();
6565
expect(component.value()).toEqual(1000);
6666

6767
component.handleQtyValue(true);
@@ -100,7 +100,7 @@ define(['squire'], function (Squire) {
100100
component.value(100);
101101
component.handleQtyValue(false);
102102

103-
expect(component.disabled()).toBeFalsy();
103+
expect(component.disabled()).toBeFalse();
104104
expect(component.value()).toEqual(100);
105105
});
106106
});

dev/tests/js/jasmine/tests/app/code/Magento/Customer/adminhtml/js/view/form/components/insert-listing.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
2323
};
2424

2525
beforeEach(function () {
26-
obj = new Constr({
27-
name: 'content_name',
28-
selections: function () {
29-
return selectionsProvider;
30-
}
31-
});
26+
obj = new Constr({ name: 'content_name' });
3227
});
3328

3429
describe('Check delete massaction process', function () {
@@ -45,6 +40,10 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
4540

4641
it('Check ids are retrieved from selections provider if they are NOT in data', function () {
4742
obj._delete = jasmine.createSpy();
43+
obj.selections = jasmine.createSpy().and.callFake(function () {
44+
return selectionsProvider;
45+
});
46+
4847
obj.onMassAction({
4948
action: 'delete',
5049
data: {}
@@ -60,6 +59,10 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
6059
get: jasmine.createSpy().and.returnValues(2, 3),
6160
set: jasmine.createSpy()
6261
};
62+
obj.selections = jasmine.createSpy().and.callFake(function () {
63+
return selectionsProvider;
64+
});
65+
6366
obj.onMassAction(data);
6467

6568
expect(selectionsProvider.selected).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)