File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed
dev/tests/js/jasmine/tests/lib/mage Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
-
5
+ /* eslint-disable max-nested-callbacks */
6
6
define ( [
7
7
'mageUtils' ,
8
- 'moment'
9
- ] , function ( utils , moment ) {
8
+ 'moment' ,
9
+ 'jquery'
10
+ ] , function ( utils , moment , $ ) {
10
11
'use strict' ;
11
12
12
13
describe ( 'mageUtils' , function ( ) {
@@ -681,5 +682,23 @@ define([
681
682
}
682
683
}
683
684
} ) ;
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
+ } ) ;
684
703
} ) ;
685
704
} ) ;
Original file line number Diff line number Diff line change @@ -178,13 +178,15 @@ define([
178
178
}
179
179
} )
180
180
. 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
+ }
188
190
} )
189
191
. always ( function ( ) {
190
192
if ( ! config . ignoreProcessEvents ) {
You can’t perform that action at this time.
0 commit comments