This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -463,4 +463,34 @@ describe('Images addon', function () {
463463 files : [ { type : 'image/jpeg' , size : 1001 } ]
464464 } ) ;
465465 } ) ;
466+
467+ it ( 'calls callback function after failing upload' , function ( done ) {
468+ this . addon . options . fileUploadOptions . maxFileSize = 1000 ;
469+ this . addon . options . uploadFailed = function ( ) {
470+ expect ( true ) . toBe ( true ) ;
471+ done ( ) ;
472+ } ;
473+
474+ this . $el . find ( 'p' ) . click ( ) ;
475+
476+ this . addon . uploadAdd ( null , {
477+ files : [ { type : 'image/jpeg' , size : 1001 } ]
478+ } ) ;
479+ } ) ;
480+
481+ it ( 'show alert if callback is no function' , function ( done ) {
482+ this . addon . options . fileUploadOptions . maxFileSize = 1000 ;
483+ this . addon . options . uploadFailed = "string" ;
484+
485+ spyOn ( window , 'alert' ) . and . callFake ( function ( text ) {
486+ expect ( text ) . not . toBe ( null ) ;
487+ done ( ) ;
488+ } ) ;
489+
490+ this . $el . find ( 'p' ) . click ( ) ;
491+
492+ this . addon . uploadAdd ( null , {
493+ files : [ { type : 'image/jpeg' , size : 1001 } ]
494+ } ) ;
495+ } ) ;
466496} ) ;
Original file line number Diff line number Diff line change 7373 acceptFileTypesError : 'This file is not in a supported format: ' ,
7474 maxFileSizeError : 'This file is too big: '
7575 }
76+ // uploadError: function($el, data) {}
7677 // uploadCompleted: function ($el, data) {}
7778 } ;
7879
249250 uploadErrors . push ( this . options . messages . maxFileSizeError + file . name ) ;
250251 }
251252 if ( uploadErrors . length > 0 ) {
253+ if ( this . options . uploadFailed && typeof this . options . uploadFailed === "function" ) {
254+ this . options . uploadFailed ( uploadErrors , data ) ;
255+
256+ return ;
257+ }
258+
252259 alert ( uploadErrors . join ( "\n" ) ) ;
260+
253261 return ;
254262 }
255263
You can’t perform that action at this time.
0 commit comments