Skip to content

Commit 7ac754e

Browse files
committed
MAGETWO-89675: Build Stabilization
Fix isolation of JSUnit tests
1 parent d11c38e commit 7ac754e

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/components/product-ui-select-test.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ define([
1313
'use strict';
1414

1515
describe('Magento_Catalog/js/components/product-ui-select', function () {
16-
var obj,
17-
jQueryMethodsOverridden = {};
16+
var obj;
1817

1918
beforeEach(function () {
2019
obj = new Constr({
@@ -24,14 +23,6 @@ define([
2423
options: [],
2524
value: ''
2625
});
27-
28-
jQueryMethodsOverridden = {};
29-
});
30-
31-
afterEach(function () {
32-
_.each(jQueryMethodsOverridden, function (value, key) {
33-
$.fn[key] = value;
34-
});
3526
});
3627

3728
describe('"validateInitialValue" method', function () {
@@ -40,8 +31,7 @@ define([
4031
});
4132

4233
it('Should call not call ajax if value is empty', function () {
43-
jQueryMethodsOverridden.ajax = $.ajax;
44-
spyOn($, 'ajax');
34+
$.ajax = jasmine.createSpy();
4535

4636
spyOn(obj, 'validationLoading');
4737
spyOn(obj, 'value').and.returnValue('');
@@ -60,8 +50,7 @@ define([
6050
value: 'hello world'
6151
};
6252

63-
jQueryMethodsOverridden.ajax = $.ajax;
64-
spyOn($, 'ajax').and.callFake(function (request) {
53+
$.ajax = jasmine.createSpy().and.callFake(function (request) {
6554
successCallback = request.success.bind(obj);
6655
completeCallback = request.complete.bind(obj);
6756
});

dev/tests/js/jasmine/tests/app/code/Magento/Review/view/frontend/web/js/process-review.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define([
3131
it('Should automatically load reviews after page load if review tab is active', function () {
3232
element.addClass('active');
3333

34-
spyOn($, 'ajax').and.callFake(function () {
34+
$.ajax = jasmine.createSpy().and.callFake(function () {
3535
var d = $.Deferred();
3636

3737
d.promise().complete = function () {};
@@ -45,7 +45,7 @@ define([
4545
});
4646

4747
it('Should not automatically load reviews after page load if review tab is not active', function () {
48-
spyOn($, 'ajax').and.callFake(function () {
48+
$.ajax = jasmine.createSpy().and.callFake(function () {
4949
var d = $.Deferred();
5050

5151
d.promise().complete = function () {};
@@ -59,7 +59,7 @@ define([
5959
});
6060

6161
it('Should load reviews if non active review tab was opened', function () {
62-
spyOn($, 'ajax').and.callFake(function () {
62+
$.ajax = jasmine.createSpy().and.callFake(function () {
6363
var d = $.Deferred();
6464

6565
d.promise().complete = function () {};

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/ui-select.test.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ define([
1414
'use strict';
1515

1616
describe('Magento_Ui/js/form/element/ui-select', function () {
17-
var obj,
18-
jQueryMethodsOverridden = {};
17+
var obj;
1918

2019
beforeEach(function () {
2120
obj = new Constr({
@@ -26,14 +25,6 @@ define([
2625

2726
obj.value = ko.observableArray([]);
2827
obj.cacheOptions.plain = [];
29-
30-
jQueryMethodsOverridden = {};
31-
});
32-
33-
afterEach(function () {
34-
_.each(jQueryMethodsOverridden, function (value, key) {
35-
$.fn[key] = value;
36-
});
3728
});
3829

3930
describe('"initialize" method', function () {
@@ -657,9 +648,7 @@ define([
657648
}
658649
};
659650

660-
jQueryMethodsOverridden.ajax = $.ajax;
661-
662-
spyOn($, 'ajax').and.callFake(function (request) {
651+
$.ajax = jasmine.createSpy().and.callFake(function (request) {
663652
ajaxRequest = request.success.bind(obj);
664653
});
665654

0 commit comments

Comments
 (0)