Skip to content
Permalink
Browse files

Simplified error message.

  • Loading branch information
Tade0 committed Jun 2, 2015
1 parent 0794c36 commit a07614953bdf915aabaf9831963baf492d21843d
Showing with 13 additions and 22 deletions.
  1. +2 −2 plugins/filetools/lang/en.js
  2. +3 −6 plugins/filetools/plugin.js
  3. +8 −14 tests/plugins/filetools/filetools.js
@@ -9,5 +9,5 @@ CKEDITOR.plugins.setLang( 'filetools', 'en', {
httpError403: 'HTTP error occurred during file uploading (403: Forbidden).',
httpError: 'HTTP error occurred during file uploading (error status: %1).',
noUrlError: 'Upload URL is not defined.',
responseError: 'Incorrect server response format: %1'
} );
responseError: 'Incorrect server response.'
} );
@@ -178,12 +178,9 @@
}
} catch ( err ) {
// Response parsing error.
var responseError = fileLoader.lang.filetools.responseError;
if ( xhr.getResponseHeader( 'content-type' ).search( 'text/plain' ) !== -1 ) {
data.message = responseError.replace( '%1', xhr.responseText );
} else {
data.message = responseError.replace( ': %1', '.' );
}
data.message = fileLoader.lang.filetools.responseError;
window.console && window.console.log( xhr.responseText );

evt.cancel();
}
}, null, null, 999 );
@@ -173,35 +173,29 @@
},

'test fileUploadResponse event': function() {
var log = window.console && sinon.spy( window.console, 'log' );

var message = 'Not a JSON';
var contentType;
var error = 'Error.';

//Mock
// Mock.
var data = {
fileLoader: {
xhr: {
getResponseHeader: function() {
return contentType;
},
responseText: message
},

lang: {
filetools: {
responseError: 'Error: %1'
responseError: error
}
}
}
};

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.' );
assert.areEqual( data.message, error );
assert.isTrue( log ? log.calledWith( message ) : true );
}
} );
} )();

0 comments on commit a076149

Please sign in to comment.
You can’t perform that action at this time.