/**
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import HorizontalRuleEditing from '../src/horizontalruleediting';
import HorizontalRuleCommand from '../src/horizontalrulecommand';
import { isHorizontalRuleWidget } from '../src/utils';
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
import env from '@ckeditor/ckeditor5-utils/src/env';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
describe( 'HorizontalRuleEditing', () => {
let editor, model, view, viewDocument;
testUtils.createSinonSandbox();
beforeEach( () => {
// Most tests assume non-edge environment but we do not set `contenteditable=false` on Edge so stub `env.isEdge`.
testUtils.sinon.stub( env, 'isEdge' ).get( () => false );
return VirtualTestEditor
.create( {
plugins: [ HorizontalRuleEditing ]
} )
.then( newEditor => {
editor = newEditor;
model = editor.model;
view = editor.editing.view;
viewDocument = view.document;
} );
} );
it( 'should be loaded', () => {
expect( editor.plugins.get( HorizontalRuleEditing ) ).to.be.instanceOf( HorizontalRuleEditing );
} );
it( 'should set proper schema rules', () => {
expect( model.schema.checkChild( [ '$root' ], 'horizontalRule' ) ).to.be.true;
expect( model.schema.isObject( 'horizontalRule' ) ).to.be.true;
expect( model.schema.checkChild( [ '$root', 'horizontalRule' ], '$text' ) ).to.be.false;
expect( model.schema.checkChild( [ '$root', '$block' ], 'horizontalRule' ) ).to.be.false;
} );
it( 'should register imageInsert command', () => {
expect( editor.commands.get( 'horizontalRule' ) ).to.be.instanceOf( HorizontalRuleCommand );
} );
describe( 'conversion in data pipeline', () => {
describe( 'model to view', () => {
it( 'should convert', () => {
setModelData( model, '