|
|
@@ -0,0 +1,147 @@
|
|
|
+/**
|
|
|
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
|
|
|
+ * For licensing, see LICENSE.md.
|
|
|
+ */
|
|
|
+
|
|
|
+/* globals document */
|
|
|
+
|
|
|
+import { BalloonToolbarEditor } from '../ckeditor';
|
|
|
+import BaseBalloonToolbarEditor from '@ckeditor/ckeditor5-editor-balloon-toolbar/src/balloontoolbareditor';
|
|
|
+
|
|
|
+describe( 'BalloonToolbarEditor', () => {
|
|
|
+ let editor, editorElement;
|
|
|
+
|
|
|
+ beforeEach( () => {
|
|
|
+ editorElement = document.createElement( 'div' );
|
|
|
+ editorElement.innerHTML = '<p><strong>foo</strong> bar</p>';
|
|
|
+
|
|
|
+ document.body.appendChild( editorElement );
|
|
|
+ } );
|
|
|
+
|
|
|
+ afterEach( () => {
|
|
|
+ editorElement.remove();
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'buid', () => {
|
|
|
+ it( 'contains plugins', () => {
|
|
|
+ expect( BalloonToolbarEditor.build.plugins ).to.not.be.empty;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'contains config', () => {
|
|
|
+ expect( BalloonToolbarEditor.build.config.toolbar ).to.not.be.empty;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'create()', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ return BalloonToolbarEditor.create( editorElement )
|
|
|
+ .then( newEditor => {
|
|
|
+ editor = newEditor;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ afterEach( () => {
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'creates an instance which inherits from the BalloonToolbarEditor', () => {
|
|
|
+ expect( editor ).to.be.instanceof( BalloonToolbarEditor );
|
|
|
+ expect( editor ).to.be.instanceof( BaseBalloonToolbarEditor );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'loads data from the editor element', () => {
|
|
|
+ expect( editor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'destroy()', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ return BalloonToolbarEditor.create( editorElement )
|
|
|
+ .then( newEditor => {
|
|
|
+ editor = newEditor;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'sets the data back to the editor element', () => {
|
|
|
+ editor.setData( '<p>foo</p>' );
|
|
|
+
|
|
|
+ return editor.destroy()
|
|
|
+ .then( () => {
|
|
|
+ expect( editorElement.innerHTML ).to.equal( '<p>foo</p>' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'plugins', () => {
|
|
|
+ it( 'paragraph works', () => {
|
|
|
+ const data = '<p>Some text inside a paragraph.</p>';
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'basic-styles work', () => {
|
|
|
+ const data = [
|
|
|
+ '<p>',
|
|
|
+ '<strong>Test:strong</strong>',
|
|
|
+ '<i>Test:i</i>',
|
|
|
+ '</p>'
|
|
|
+ ].join( '' );
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'block-quote works', () => {
|
|
|
+ const data = '<blockquote><p>Quote</p></blockquote>';
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'heading works', () => {
|
|
|
+ const data = [
|
|
|
+ '<h2>Heading 1.</h2>',
|
|
|
+ '<h3>Heading 1.1</h3>',
|
|
|
+ '<h4>Heading 1.1.1</h4>',
|
|
|
+ '<h4>Heading 1.1.2</h4>',
|
|
|
+ '<h3>Heading 1.2</h3>',
|
|
|
+ '<h4>Heading 1.2.1</h4>',
|
|
|
+ '<h2>Heading 2</h2>'
|
|
|
+ ].join( '' );
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'image works', () => {
|
|
|
+ const data = '<figure class="image"><img src="./manual/sample.jpg"></figure>';
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'list works', () => {
|
|
|
+ const data = [
|
|
|
+ '<ul>',
|
|
|
+ '<li>Item 1.</li>',
|
|
|
+ '<li>Item 2.</li>',
|
|
|
+ '</ul>',
|
|
|
+ '<ol>',
|
|
|
+ '<li>Item 1.</li>',
|
|
|
+ '<li>Item 2.</li>',
|
|
|
+ '</ol>'
|
|
|
+ ].join( '' );
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'link works', () => {
|
|
|
+ const data = '<p><a href="//ckeditor.com">CKEditor.com</a></p>';
|
|
|
+
|
|
|
+ editor.setData( data );
|
|
|
+ expect( editor.getData() ).to.equal( data );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+} );
|