/** * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; import TableEditing from '../src/tableediting'; describe( 'TableEditing', () => { let editor, model; beforeEach( () => { return VirtualTestEditor .create( { plugins: [ TableEditing, Paragraph ] } ) .then( newEditor => { editor = newEditor; model = editor.model; } ); } ); afterEach( () => { editor.destroy(); } ); it( 'should set proper schema rules', () => { } ); describe( 'conversion in data pipeline', () => { describe( 'model to view', () => { it( 'should create tbody section', () => { setModelData( model, 'foo[]
' ); expect( editor.getData() ).to.equal( '
foo
' ); } ); it( 'should create thead section', () => { setModelData( model, 'foo[]
' ); expect( editor.getData() ).to.equal( '
foo
' ); } ); it( 'should create thead and tbody sections in proper order', () => { setModelData( model, '' + 'foo' + 'bar' + 'baz[]' + '
' ); expect( editor.getData() ).to.equal( '' + '' + '' + '
foo
bar
baz
' ); } ); it( 'should convert rowspan on tableCell', () => { setModelData( model, 'foo[]
' ); expect( editor.getData() ).to.equal( '
foo
' ); } ); it( 'should convert colspan on tableCell', () => { setModelData( model, 'foo[]
' ); expect( editor.getData() ).to.equal( '
foo
' ); } ); } ); describe( 'view to model', () => { it( 'should convert table', () => { editor.setData( '
foo
' ); expect( getModelData( model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); } ); } ); } );