|
@@ -6,23 +6,22 @@
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
import Paragraph from '/ckeditor5/paragraph/paragraph.js';
|
|
import Paragraph from '/ckeditor5/paragraph/paragraph.js';
|
|
|
-import Editor from '/ckeditor5/editor.js';
|
|
|
|
|
-import StandardCreator from '/ckeditor5/creator/standardcreator.js';
|
|
|
|
|
|
|
+import VirtualTestEditor from '/tests/ckeditor5/_utils/virtualtesteditor.js';
|
|
|
import { getData } from '/tests/engine/_utils/model.js';
|
|
import { getData } from '/tests/engine/_utils/model.js';
|
|
|
|
|
|
|
|
describe( 'Paragraph feature', () => {
|
|
describe( 'Paragraph feature', () => {
|
|
|
- let editor, document;
|
|
|
|
|
|
|
+ let editor, doc;
|
|
|
|
|
|
|
|
beforeEach( () => {
|
|
beforeEach( () => {
|
|
|
- editor = new Editor( null, {
|
|
|
|
|
- creator: StandardCreator,
|
|
|
|
|
- features: [ Paragraph ]
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- return editor.init().then( () => {
|
|
|
|
|
- document = editor.document;
|
|
|
|
|
- document.createRoot( 'main' );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ return VirtualTestEditor.create( {
|
|
|
|
|
+ features: [ Paragraph ]
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( newEditor => {
|
|
|
|
|
+ editor = newEditor;
|
|
|
|
|
+ doc = editor.document;
|
|
|
|
|
+
|
|
|
|
|
+ doc.createRoot();
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should be loaded', () => {
|
|
it( 'should be loaded', () => {
|
|
@@ -30,29 +29,29 @@ describe( 'Paragraph feature', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should set proper schema rules', () => {
|
|
it( 'should set proper schema rules', () => {
|
|
|
- expect( document.schema.hasItem( 'paragraph' ) ).to.be.true;
|
|
|
|
|
- expect( document.schema.check( { name: 'paragraph', inside: '$root' } ) ).to.be.true;
|
|
|
|
|
- expect( document.schema.check( { name: '$inline', inside: 'paragraph' } ) ).to.be.true;
|
|
|
|
|
|
|
+ expect( doc.schema.hasItem( 'paragraph' ) ).to.be.true;
|
|
|
|
|
+ expect( doc.schema.check( { name: 'paragraph', inside: '$root' } ) ).to.be.true;
|
|
|
|
|
+ expect( doc.schema.check( { name: '$inline', inside: 'paragraph' } ) ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should convert paragraph', () => {
|
|
it( 'should convert paragraph', () => {
|
|
|
editor.setData( '<p>foobar</p>' );
|
|
editor.setData( '<p>foobar</p>' );
|
|
|
|
|
|
|
|
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
|
|
|
|
|
|
|
+ expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
|
|
|
expect( editor.getData() ).to.equal( '<p>foobar</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foobar</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should convert paragraph only', () => {
|
|
it( 'should convert paragraph only', () => {
|
|
|
editor.setData( '<p>foo<b>baz</b>bar</p>' );
|
|
editor.setData( '<p>foo<b>baz</b>bar</p>' );
|
|
|
|
|
|
|
|
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foobazbar</paragraph>' );
|
|
|
|
|
|
|
+ expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobazbar</paragraph>' );
|
|
|
expect( editor.getData() ).to.equal( '<p>foobazbar</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foobazbar</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should convert multiple paragraphs', () => {
|
|
it( 'should convert multiple paragraphs', () => {
|
|
|
editor.setData( '<p>foo</p><p>baz</p>' );
|
|
editor.setData( '<p>foo</p><p>baz</p>' );
|
|
|
|
|
|
|
|
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foo</paragraph><paragraph>baz</paragraph>' );
|
|
|
|
|
|
|
+ expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foo</paragraph><paragraph>baz</paragraph>' );
|
|
|
expect( editor.getData() ).to.equal( '<p>foo</p><p>baz</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foo</p><p>baz</p>' );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|