Skip to content

Commit da4551d

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-41575' into 2.4-develop-pr56
2 parents 8d38907 + a84a34d commit da4551d

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

dev/tests/js/jasmine/tests/lib/mage/misc.test.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
5+
/* eslint-disable max-nested-callbacks */
66
define([
77
'mageUtils',
8-
'moment'
9-
], function (utils, moment) {
8+
'moment',
9+
'jquery'
10+
], function (utils, moment, $) {
1011
'use strict';
1112

1213
describe('mageUtils', function () {
@@ -681,5 +682,23 @@ define([
681682
}
682683
}
683684
});
685+
686+
it('Check ajaxSubmit method', function () {
687+
var options = {
688+
data: {}
689+
},
690+
config = {
691+
ajaxSaveType: 'default'
692+
},
693+
d = new $.Deferred();
694+
695+
spyOn($, 'ajax').and.callFake(function () {
696+
d.reject();
697+
698+
return d.promise();
699+
});
700+
utils.ajaxSubmit(options, config);
701+
expect($.ajax).toHaveBeenCalled();
702+
});
684703
});
685704
});

lib/web/mage/utils/misc.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ define([
178178
}
179179
})
180180
.fail(function () {
181-
config.response.status(undefined);
182-
config.response.status(false);
183-
config.response.data({
184-
error: true,
185-
messages: 'Something went wrong.',
186-
t: t
187-
});
181+
if (config.response) {
182+
config.response.status(undefined);
183+
config.response.status(false);
184+
config.response.data({
185+
error: true,
186+
messages: 'Something went wrong.',
187+
t: t
188+
});
189+
}
188190
})
189191
.always(function () {
190192
if (!config.ignoreProcessEvents) {

0 commit comments

Comments
 (0)