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 22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5-
5+ /* eslint-disable max-nested-callbacks */
66define ( [
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} ) ;
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments