| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- import HeadingsEngine from '/ckeditor5/headings/headingsengine.js';
- import Paragraph from '/ckeditor5/paragraph/paragraph.js';
- import VirtualTestEditor from '/tests/core/_utils/virtualtesteditor.js';
- import HeadingsCommand from '/ckeditor5/headings/headingscommand.js';
- import { getData } from '/tests/engine/_utils/model.js';
- describe( 'HeadingsEngine', () => {
- let editor, document;
- beforeEach( () => {
- return VirtualTestEditor.create( {
- features: [ HeadingsEngine ]
- } )
- .then( newEditor => {
- editor = newEditor;
- document = editor.document;
- } );
- } );
- it( 'should be loaded', () => {
- expect( editor.plugins.get( HeadingsEngine ) ).to.be.instanceOf( HeadingsEngine );
- } );
- it( 'should load paragraph feature', () => {
- expect( editor.plugins.get( Paragraph ) ).to.be.instanceOf( Paragraph );
- } );
- it( 'should set proper schema rules', () => {
- expect( document.schema.hasItem( 'heading1' ) ).to.be.true;
- expect( document.schema.hasItem( 'heading2' ) ).to.be.true;
- expect( document.schema.hasItem( 'heading3' ) ).to.be.true;
- expect( document.schema.check( { name: 'heading1', inside: '$root' } ) ).to.be.true;
- expect( document.schema.check( { name: '$inline', inside: 'heading1' } ) ).to.be.true;
- expect( document.schema.check( { name: 'heading2', inside: '$root' } ) ).to.be.true;
- expect( document.schema.check( { name: '$inline', inside: 'heading2' } ) ).to.be.true;
- expect( document.schema.check( { name: 'heading3', inside: '$root' } ) ).to.be.true;
- expect( document.schema.check( { name: '$inline', inside: 'heading3' } ) ).to.be.true;
- } );
- it( 'should register format command', () => {
- expect( editor.commands.has( 'headings' ) ).to.be.true;
- const command = editor.commands.get( 'headings' );
- expect( command ).to.be.instanceOf( HeadingsCommand );
- } );
- it( 'should convert heading1', () => {
- editor.setData( '<h2>foobar</h2>' );
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
- expect( editor.getData() ).to.equal( '<h2>foobar</h2>' );
- } );
- it( 'should convert heading2', () => {
- editor.setData( '<h3>foobar</h3>' );
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading2>foobar</heading2>' );
- expect( editor.getData() ).to.equal( '<h3>foobar</h3>' );
- } );
- it( 'should convert heading3', () => {
- editor.setData( '<h4>foobar</h4>' );
- expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading3>foobar</heading3>' );
- expect( editor.getData() ).to.equal( '<h4>foobar</h4>' );
- } );
- } );
|