Skip to content

Commit

Permalink
Added test for image upload error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tade0 committed Jun 1, 2015
1 parent 77a9e87 commit 0794c36
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/plugins/filetools/filetools.js
Expand Up @@ -170,6 +170,38 @@
sinon.stub( repository.loaders[ 1 ], 'isFinished' ).returns( true );

assert.isTrue( repository.isFinished(), '3/3' );
},

'test fileUploadResponse event': function() {
var message = 'Not a JSON';
var contentType;

//Mock
var data = {
fileLoader: {
xhr: {
getResponseHeader: function() {
return contentType;
},
responseText: message
},
lang: {
filetools: {
responseError: 'Error: %1'
}
}
}
};

contentType = 'text/plain';

this.editor.fire( 'fileUploadResponse', data );
assert.areEqual( data.message, 'Error: ' + message );

contentType = 'text/html';

this.editor.fire( 'fileUploadResponse', data );
assert.areEqual( data.message, 'Error.' );
}
} );
} )();

0 comments on commit 0794c36

Please sign in to comment.