@@ -160,7 +160,7 @@ describe('Images addon', function () {
160160 } ) ;
161161 } ) ;
162162
163- it ( 'truggers input event twice on showImage for preview' , function ( done ) {
163+ it ( 'triggers input event twice on showImage for preview' , function ( done ) {
164164 var inputTriggerCount = 0 ,
165165 stubbedImage = jasmine . createSpy ( 'image' ) ,
166166 context = this . $el . prepend ( '<div class="medium-insert-images medium-insert-active">' +
@@ -184,6 +184,38 @@ describe('Images addon', function () {
184184 stubbedImage . onload ( ) ;
185185 } ) ;
186186
187+ it ( 'calls uploadCompleted when preview is enabled' , function ( done ) {
188+ var stubbedImage = jasmine . createSpy ( 'image' ) ,
189+ context = this . $el . prepend ( '<div class="medium-insert-images medium-insert-active">' +
190+ '<figure><img src="data:" alt=""></figure>' +
191+ '</div>' ) ;
192+
193+ spyOn ( this . addon , 'getDOMImage' ) . and . returnValue ( stubbedImage ) ;
194+
195+ this . addon . options . uploadCompleted = function ( ) {
196+ expect ( true ) . toBe ( true ) ;
197+ done ( ) ;
198+ } ;
199+
200+ this . addon . showImage ( 'http://image.co' , {
201+ context : context
202+ } ) ;
203+ stubbedImage . onload ( ) ;
204+ } ) ;
205+
206+ it ( 'calls uploadCompleted when preview is disabled' , function ( done ) {
207+ this . addon . options . preview = false ;
208+
209+ this . addon . options . uploadCompleted = function ( ) {
210+ expect ( true ) . toBe ( true ) ;
211+ done ( ) ;
212+ } ;
213+
214+ this . addon . showImage ( null , {
215+ submit : function ( ) { }
216+ } ) ;
217+ } ) ;
218+
187219 it ( 'supports selecting image' , function ( ) {
188220 this . $el . find ( 'p' )
189221 . addClass ( 'medium-insert-images' )
@@ -370,23 +402,6 @@ describe('Images addon', function () {
370402 $ ( '.medium-insert-images-toolbar2 .medium-editor-action' ) . first ( ) . click ( ) ;
371403 } ) ;
372404
373- it ( 'calls uploadCompleted callback' , function ( done ) {
374- this . addon . options . uploadCompleted = function ( ) {
375- expect ( true ) . toBe ( true ) ;
376- done ( ) ;
377- } ;
378-
379- spyOn ( this . addon , 'showImage' ) ;
380-
381- this . addon . uploadDone ( null , {
382- result : {
383- files : [
384- { url : 'test.jpg' }
385- ]
386- }
387- } ) ;
388- } ) ;
389-
390405 it ( 'validatates file type on upload' , function ( done ) {
391406 spyOn ( window , 'alert' ) . and . callFake ( function ( text ) {
392407 expect ( text ) . toMatch ( / ^ T h i s f i l e i s n o t i n a s u p p o r t e d f o r m a t / ) ;
0 commit comments