Преглед на файлове

Made PluginCollection forward the original error.

Piotrek Koszuliński преди 10 години
родител
ревизия
9cbd41d941
променени са 2 файла, в които са добавени 16 реда и са изтрити 7 реда
  1. 3 3
      packages/ckeditor5-engine/src/plugincollection.js
  2. 13 4
      packages/ckeditor5-engine/tests/plugincollection/plugincollection.js

+ 3 - 3
packages/ckeditor5-engine/src/plugincollection.js

@@ -12,7 +12,7 @@
  * @extends Collection
  */
 
-CKEDITOR.define( [ 'collection', 'promise', 'ckeditorerror' ], function( Collection, Promise, CKEditorError ) {
+CKEDITOR.define( [ 'collection', 'promise', 'log' ], function( Collection, Promise, log ) {
 	class PluginCollection extends Collection {
 		/**
 		 * Creates an instance of the PluginCollection class, initializing it with a set of plugins.
@@ -76,14 +76,14 @@ CKEDITOR.define( [ 'collection', 'promise', 'ckeditorerror' ], function( Collect
 							);
 						},
 						// Error callback.
-						function() {
+						function( err ) {
 							/**
 							 * It was not possible to load the plugin.
 							 *
 							 * @error plugincollection-load
 							 * @param {String} plugin The name of the plugin that could not be loaded.
 							 */
-							var err = new CKEditorError( 'plugincollection-load: It was not possible to load the plugin.', { plugin: plugin } );
+							log.error( 'plugincollection-load: It was not possible to load the plugin.', { plugin: plugin } );
 							reject( err );
 						}
 					);

+ 13 - 4
packages/ckeditor5-engine/tests/plugincollection/plugincollection.js

@@ -7,10 +7,13 @@
 
 'use strict';
 
-var modules = bender.amd.require( 'plugincollection', 'plugin', 'editor', 'ckeditorerror' );
+var modules = bender.amd.require( 'plugincollection', 'plugin', 'editor', 'log' );
 var editor;
 var PluginA, PluginB;
 
+var sandbox = sinon.sandbox.create();
+afterEach( sandbox.restore.bind( sandbox ) );
+
 before( function() {
 	var Editor = modules.editor;
 	var Plugin = modules.plugin;
@@ -169,7 +172,9 @@ describe( 'load', function() {
 
 	it( 'should throw an error for invalid plugins', function() {
 		var PluginCollection = modules.plugincollection;
-		var CKEditorError = modules.ckeditorerror;
+		var log = modules.log;
+
+		var logSpy = sandbox.stub( log, 'error' );
 
 		var plugins = new PluginCollection( editor );
 
@@ -178,8 +183,12 @@ describe( 'load', function() {
 				throw new Error( 'Test error: this promise should not be resolved successfully' );
 			} )
 			.catch( function( err ) {
-				expect( err ).to.be.an.instanceof( CKEditorError );
-				expect( err.data ).to.have.property( 'plugin', 'BAD' );
+				expect( err ).to.be.an.instanceof( Error );
+				// Make sure it's the Require.JS error, not the one thrown above.
+				expect( err ).to.have.property( 'requireType', 'scripterror' );
+
+				sinon.assert.calledOnce( logSpy );
+				expect( logSpy.args[ 0 ][ 0 ] ).to.match( /^plugincollection-load:/ );
 			} );
 	} );
 } );