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

Merge branch t/ckeditor5-watchdog/1

Internal: Add context to CKEditorError exceptions. Required by ckeditor/ckeditor5-watchdog#2.
Piotr Jasiun преди 6 години
родител
ревизия
0ee3cd5b5c
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 1 1
      packages/ckeditor5-widget/src/widgettoolbarrepository.js
  2. 3 3
      packages/ckeditor5-widget/tests/widgettoolbarrepository.js

+ 1 - 1
packages/ckeditor5-widget/src/widgettoolbarrepository.js

@@ -126,7 +126,7 @@ export default class WidgetToolbarRepository extends Plugin {
 			 * @error widget-toolbar-duplicated
 			 * @param toolbarId Toolbar id.
 			 */
-			throw new CKEditorError( 'widget-toolbar-duplicated: Toolbar with the given id was already added.', { toolbarId } );
+			throw new CKEditorError( 'widget-toolbar-duplicated: Toolbar with the given id was already added.', this, { toolbarId } );
 		}
 
 		toolbarView.fillFromConfig( items, editor.ui.componentFactory );

+ 3 - 3
packages/ckeditor5-widget/tests/widgettoolbarrepository.js

@@ -18,7 +18,7 @@ import View from '@ckeditor/ckeditor5-ui/src/view';
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
+import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 describe( 'WidgetToolbarRepository', () => {
 	let editor, model, balloon, widgetToolbarRepository, editorElement;
@@ -82,12 +82,12 @@ describe( 'WidgetToolbarRepository', () => {
 				getRelatedElement: () => null
 			} );
 
-			expect( () => {
+			expectToThrowCKEditorError( () => {
 				widgetToolbarRepository.register( 'fake', {
 					items: editor.config.get( 'fake.toolbar' ),
 					getRelatedElement: () => null
 				} );
-			} ).to.throw( CKEditorError, /^widget-toolbar-duplicated/ );
+			}, /^widget-toolbar-duplicated/, editor );
 		} );
 	} );