Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsobol committed Jan 13, 2023
1 parent c8e07c3 commit 512f13a
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import TableCaption from '../../src/tablecaption';
import TableToolbar from '../../src/tabletoolbar';
import Table from '../../src/table';
import TableProperties from '../../src/tableproperties';
import PlainTableOutput from '../../src/plaintableoutput';

// ClassicTestEditor can't be used, as it doesn't handle the focus, which is needed to test resizer visual cues.
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
Expand Down Expand Up @@ -2558,6 +2559,53 @@ describe( 'TableColumnResizeEditing', () => {
expect( initialViewColumnWidthsPx ).to.deep.equal( finalViewColumnWidthsPx );
} );
} );

describe( 'PlainTableOutput', () => {
let ptoEditor;

beforeEach( async () => {
ptoEditor = await createEditor( {
plugins: [ Table, TableColumnResize, Paragraph, PlainTableOutput ]
} );
} );

afterEach( async () => {
await ptoEditor.destroy();
} );

it( 'should not crash', () => {
const table = modelTable(
[ [ 'Some', 'Data' ] ],
{ columnWidths: '80%,20%', tableWidth: '100%' }
);
setModelData( ptoEditor.model, table );

expect( () => ptoEditor.getData() ).to.not.throw();
} );

it( 'should produce table not wrapped in <figure>', () => {
const table = modelTable(
[ [ 'Some', 'Data' ] ],
{ columnWidths: '80%,20%', tableWidth: '100%' }
);
setModelData( ptoEditor.model, table );

expect( ptoEditor.getData() ).to.equal(
'<table class="ck-table-resized" style="width:100%;">' +
'<colgroup>' +
'<col style="width:80%;">' +
'<col style="width:20%;">' +
'</colgroup>' +
'<tbody>' +
'<tr>' +
'<td>Some</td>' +
'<td>Data</td>' +
'</tr>' +
'</tbody>' +
'</table>'
);
} );
} );
} );

async function createEditor( configCustomization, additionalPlugins ) {
Expand Down

0 comments on commit 512f13a

Please sign in to comment.