Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch t/ckeditor5-watchdog/1
Browse files Browse the repository at this point in the history
Internal: Add context to CKEditorError exceptions. Required by ckeditor/ckeditor5-watchdog#2.
  • Loading branch information
Piotr Jasiun committed Jul 2, 2019
2 parents 26c4ef1 + 05c5a5a commit d1ba20b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/decouplededitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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
);
}

Expand Down
13 changes: 9 additions & 4 deletions tests/decouplededitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>';

Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions tests/decouplededitorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -67,7 +67,7 @@ describe( 'DecoupledEditorUI', () => {
} );

it( 'binds view.editable#isFocused', () => {
utils.assertBinding(
assertBinding(
view.editable,
{ isFocused: false },
[
Expand Down

0 comments on commit d1ba20b

Please sign in to comment.