Browse Source

Merge branch t/ckeditor5-watchdog/1

Internal: Add context to CKEditorError exceptions. Required by ckeditor/ckeditor5-watchdog#2.
Piotr Jasiun 6 years ago
parent
commit
5d37cf0098

+ 6 - 2
packages/ckeditor5-editor-balloon/src/ballooneditor.js

@@ -200,7 +200,10 @@ export default class BalloonEditor extends Editor {
 
 			if ( isHTMLElement && sourceElementOrData.tagName === 'TEXTAREA' ) {
 				// Documented in core/editor/editor.js
-				throw new CKEditorError( 'editor-wrong-element: This type of editor cannot be initialized inside <textarea> element.' );
+				throw new CKEditorError(
+					'editor-wrong-element: This type of editor cannot be initialized inside <textarea> element.',
+					null
+				);
 			}
 
 			const editor = new this( sourceElementOrData, config );
@@ -215,7 +218,8 @@ export default class BalloonEditor extends Editor {
 							// Documented in core/editor/editorconfig.jdoc.
 							throw new CKEditorError(
 								'editor-create-initial-data: ' +
-								'The config.initialData option cannot be used together with initial data passed in Editor.create().'
+								'The config.initialData option cannot be used together with initial data passed in Editor.create().',
+								null
 							);
 						}
 

+ 9 - 4
packages/ckeditor5-editor-balloon/tests/ballooneditor.js

@@ -24,6 +24,7 @@ import log from '@ckeditor/ckeditor5-utils/src/log';
 
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory';
+import { assertCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 describe( 'BalloonEditor', () => {
 	let editor, editorElement;
@@ -170,9 +171,11 @@ describe( 'BalloonEditor', () => {
 						expect.fail( 'Balloon editor should throw an error when both initial data are passed' );
 					},
 					err => {
-						expect( err ).to.be.an( 'error' ).with.property( 'message' ).and
+						assertCKEditorError( err,
 							// eslint-disable-next-line max-len
-							.match( /^editor-create-initial-data: The config\.initialData option cannot be used together with initial data passed in Editor\.create\(\)\./ );
+							/^editor-create-initial-data: The config\.initialData option cannot be used together with initial data passed in Editor\.create\(\)\./,
+							null
+						);
 					}
 				)
 				.then( done )
@@ -213,8 +216,10 @@ describe( 'BalloonEditor', () => {
 						expect.fail( 'Balloon editor should throw an error when is initialized in textarea.' );
 					},
 					err => {
-						expect( err ).to.be.an( 'error' ).with.property( 'message' ).and
-							.match( /^editor-wrong-element: This type of editor cannot be initialized inside <textarea> element\./ );
+						assertCKEditorError( err,
+							/^editor-wrong-element: This type of editor cannot be initialized inside <textarea> element\./,
+							null
+						);
 					}
 				)
 				.then( done )

+ 2 - 2
packages/ckeditor5-editor-balloon/tests/ballooneditorui.js

@@ -14,7 +14,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import { isElement } from 'lodash-es';
 
-import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import { assertBinding } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'BalloonEditorUI', () => {
@@ -104,7 +104,7 @@ describe( 'BalloonEditorUI', () => {
 			} );
 
 			it( 'binds view.editable#isFocused', () => {
-				utils.assertBinding(
+				assertBinding(
 					view.editable,
 					{ isFocused: false },
 					[