|
|
@@ -3,7 +3,7 @@
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
|
*/
|
|
|
|
|
|
-/* globals document, Event */
|
|
|
+/* globals document, console */
|
|
|
|
|
|
import BalloonEditorUI from '../src/ballooneditorui';
|
|
|
import BalloonEditorUIView from '../src/ballooneditoruiview';
|
|
|
@@ -21,10 +21,10 @@ import RootElement from '@ckeditor/ckeditor5-engine/src/model/rootelement';
|
|
|
|
|
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
-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;
|
|
|
@@ -37,7 +37,7 @@ describe( 'BalloonEditor', () => {
|
|
|
|
|
|
document.body.appendChild( editorElement );
|
|
|
|
|
|
- testUtils.sinon.stub( log, 'warn' ).callsFake( () => {} );
|
|
|
+ testUtils.sinon.stub( console, 'warn' ).callsFake( () => {} );
|
|
|
} );
|
|
|
|
|
|
afterEach( () => {
|
|
|
@@ -76,37 +76,6 @@ describe( 'BalloonEditor', () => {
|
|
|
expect( editor.model.document.getRoot( 'main' ) ).to.instanceof( RootElement );
|
|
|
} );
|
|
|
|
|
|
- it( 'handles form element', () => {
|
|
|
- const form = document.createElement( 'form' );
|
|
|
- const textarea = document.createElement( 'textarea' );
|
|
|
- form.appendChild( textarea );
|
|
|
- document.body.appendChild( form );
|
|
|
-
|
|
|
- // Prevents page realods in Firefox ;|
|
|
|
- form.addEventListener( 'submit', evt => {
|
|
|
- evt.preventDefault();
|
|
|
- } );
|
|
|
-
|
|
|
- return BalloonEditor.create( textarea, {
|
|
|
- plugins: [ Paragraph ]
|
|
|
- } ).then( editor => {
|
|
|
- expect( textarea.value ).to.equal( '' );
|
|
|
-
|
|
|
- editor.setData( '<p>Foo</p>' );
|
|
|
-
|
|
|
- form.dispatchEvent( new Event( 'submit', {
|
|
|
- // We need to be able to do preventDefault() to prevent page reloads in Firefox.
|
|
|
- cancelable: true
|
|
|
- } ) );
|
|
|
-
|
|
|
- expect( textarea.value ).to.equal( '<p>Foo</p>' );
|
|
|
-
|
|
|
- return editor.destroy().then( () => {
|
|
|
- form.remove();
|
|
|
- } );
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
it( 'should have undefined the #sourceElement if editor was initialized with data', () => {
|
|
|
return BalloonEditor
|
|
|
.create( '<p>Foo.</p>', {
|
|
|
@@ -214,9 +183,21 @@ describe( 'BalloonEditor', () => {
|
|
|
BalloonEditor.create( '<p>Hello world!</p>', {
|
|
|
initialData: '<p>I am evil!</p>',
|
|
|
plugins: [ Paragraph ]
|
|
|
- } ).catch( () => {
|
|
|
- done();
|
|
|
- } );
|
|
|
+ } )
|
|
|
+ .then(
|
|
|
+ () => {
|
|
|
+ expect.fail( 'Balloon editor should throw an error when both initial data are passed' );
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ assertCKEditorError( err,
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ /^editor-create-initial-data: The config\.initialData option cannot be used together with initial data passed in Editor\.create\(\)\./,
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then( done )
|
|
|
+ .catch( done );
|
|
|
} );
|
|
|
|
|
|
// ckeditor/ckeditor5-editor-classic#53
|
|
|
@@ -245,6 +226,23 @@ describe( 'BalloonEditor', () => {
|
|
|
return newEditor.destroy();
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'throws an error when is initialized in textarea', done => {
|
|
|
+ BalloonEditor.create( document.createElement( 'textarea' ) )
|
|
|
+ .then(
|
|
|
+ () => {
|
|
|
+ expect.fail( 'Balloon editor should throw an error when is initialized in textarea.' );
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ assertCKEditorError( err,
|
|
|
+ /^editor-wrong-element: This type of editor cannot be initialized inside <textarea> element\./,
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then( done )
|
|
|
+ .catch( done );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'create - events', () => {
|