Parcourir la source

Merge branch t/ckeditor5-watchdog/1

Internal: Add context to CKEditorError exceptions. Required by ckeditor/ckeditor5-watchdog#2.
Piotr Jasiun il y a 6 ans
Parent
commit
613a87ec71

+ 4 - 2
packages/ckeditor5-editor-decoupled/src/decouplededitor.js

@@ -218,7 +218,8 @@ export default class DecoupledEditor 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 );
@@ -233,7 +234,8 @@ export default class DecoupledEditor 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-decoupled/tests/decouplededitor.js

@@ -22,6 +22,7 @@ import log from '@ckeditor/ckeditor5-utils/src/log';
 
 import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import { assertCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 const editorData = '<p><strong>foo</strong> bar</p>';
 
@@ -135,9 +136,11 @@ describe( 'DecoupledEditor', () => {
 						expect.fail( 'Decoupled 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 )
@@ -151,8 +154,10 @@ describe( 'DecoupledEditor', () => {
 						expect.fail( 'Decoupled 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-decoupled/tests/decouplededitorui.js

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