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

Commit

Permalink
Merge e75dfde into 0e45057
Browse files Browse the repository at this point in the history
  • Loading branch information
msamsel committed May 16, 2019
2 parents 0e45057 + e75dfde commit ee8197d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/decouplededitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export default class DecoupledEditor extends Editor {
*/
static create( sourceElementOrData, config = {} ) {
return new Promise( resolve => {
Editor._assertAllowedSourceElement( sourceElementOrData );

const editor = new this( sourceElementOrData, config );

resolve(
Expand Down
31 changes: 28 additions & 3 deletions tests/decouplededitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,34 @@ describe( 'DecoupledEditor', () => {
DecoupledEditor.create( '<p>Hello world!</p>', {
initialData: '<p>I am evil!</p>',
plugins: [ Paragraph ]
} ).catch( () => {
done();
} );
} )
.then(
() => {
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
// 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\(\)\./ );
}
)
.then( done )
.catch( done );
} );

it( 'throws error if it is initialized in textarea', done => {
DecoupledEditor.create( document.createElement( 'textarea' ) )
.then(
() => {
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\./ );
}
)
.then( done )
.catch( done );
} );

function test( getElementOrData ) {
Expand Down

0 comments on commit ee8197d

Please sign in to comment.