/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import StrikethroughEditing from '../../src/strikethrough/strikethroughediting';
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import AttributeCommand from '../../src/attributecommand';
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';
describe( 'StrikethroughEditing', () => {
let editor, model;
beforeEach( () => {
return VirtualTestEditor
.create( {
plugins: [ Paragraph, StrikethroughEditing ]
} )
.then( newEditor => {
editor = newEditor;
model = editor.model;
} );
} );
afterEach( () => {
return editor.destroy();
} );
it( 'should have pluginName', () => {
expect( StrikethroughEditing.pluginName ).to.equal( 'StrikethroughEditing' );
} );
it( 'should be loaded', () => {
expect( editor.plugins.get( StrikethroughEditing ) ).to.be.instanceOf( StrikethroughEditing );
} );
it( 'should set proper schema rules', () => {
expect( model.schema.checkAttribute( [ '$root', '$block', '$text' ], 'strikethrough' ) ).to.be.true;
expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'strikethrough' ) ).to.be.true;
} );
it( 'should be marked with a formatting property', () => {
expect( model.schema.getAttributeProperties( 'strikethrough' ) ).to.include( {
isFormatting: true
} );
} );
it( 'its attribute is marked with a copOnEnter property', () => {
expect( model.schema.getAttributeProperties( 'strikethrough' ) ).to.include( {
copyOnEnter: true
} );
} );
describe( 'command', () => {
it( 'should register strikethrough command', () => {
const command = editor.commands.get( 'strikethrough' );
expect( command ).to.be.instanceOf( AttributeCommand );
expect( command ).to.have.property( 'attributeKey', 'strikethrough' );
} );
} );
describe( 'data pipeline conversions', () => {
it( 'should convert to strikethrough attribute', () => {
editor.setData( '
foobar
foobar
foobar
foobar
foobar
foobar
foobar
' ); expect( getModelData( model, { withoutSelection: true } ) ) .to.equal( 'foobar
foobar
foobar