| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* globals document */
- import { ClassicEditor } from '../ckeditor';
- import BaseClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic';
- import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat';
- import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
- import ClipboardPlugin from '@ckeditor/ckeditor5-clipboard/src/clipboard';
- import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph';
- import HeadingPlugin from '@ckeditor/ckeditor5-heading/src/heading';
- import ImagePlugin from '@ckeditor/ckeditor5-image/src/image';
- import ImageCaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
- import ImageStylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
- import ImageToolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
- import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
- import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
- import ListPlugin from '@ckeditor/ckeditor5-list/src/list';
- import EnterPlugin from '@ckeditor/ckeditor5-enter/src/enter';
- import TypingPlugin from '@ckeditor/ckeditor5-typing/src/typing';
- import UndoPlugin from '@ckeditor/ckeditor5-undo/src/undo';
- describe( 'ClassicEditor', () => {
- let editor, editorElement;
- beforeEach( () => {
- editorElement = document.createElement( 'div' );
- editorElement.innerHTML = '<p><strong>foo</strong> bar</p>';
- document.body.appendChild( editorElement );
- } );
- afterEach( () => {
- editorElement.remove();
- } );
- describe( 'create()', () => {
- beforeEach( () => {
- return ClassicEditor.create( editorElement )
- .then( newEditor => {
- editor = newEditor;
- } );
- } );
- afterEach( () => {
- return editor.destroy();
- } );
- it( 'creates an instance which inherits from the ClassicEditor', () => {
- expect( editor ).to.be.instanceof( ClassicEditor );
- expect( editor ).to.be.instanceof( BaseClassicEditor );
- } );
- it( 'loads data from the editor element', () => {
- expect( editor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' );
- } );
- } );
- describe( 'destroy()', () => {
- beforeEach( function () {
- return ClassicEditor.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>' );
- } );
- } );
- it( 'restores the editor element', () => {
- expect( editor.element.style.display ).to.equal( 'none' );
- return editor.destroy()
- .then( () => {
- expect( editor.element.style.display ).to.equal( '' );
- } );
- } );
- } );
- describe( 'plugins', () => {
- it( 'paragraph', () => {
- const data = '<p>Some text inside a paragraph.</p>';
- editor.setData( data );
- expect( editor.getData() ).to.equal( data );
- } );
- it( 'basic-styles', () => {
- const data = [
- '<p>',
- '<strong>Test:strong</strong>',
- '<em>Test:em</em>',
- '</p>'
- ].join( '' );
- editor.setData( data );
- expect( editor.getData() ).to.equal( data );
- } );
- it( 'heading', () => {
- 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', () => {
- const data = '<figure class="image"><img src="./manual/sample.jpg"></figure>';
- editor.setData( data );
- expect( editor.getData() ).to.equal( data );
- } );
- it( 'list', () => {
- 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', () => {
- const data = '<p><a href="//ckeditor.com">CKEditor.com</a></p>';
- editor.setData( data );
- expect( editor.getData() ).to.equal( data );
- } );
- } )
- } );
|