Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'should add missing columns to tableRows that are shorter then the longest table row (complex 1)', () => {
const parsed = parse( modelTable( [
[ '00', { rowspan: 2, contents: '10' } ],
[ '10', { colspan: 2, contents: '12' } ],
[ '20', '21' ]
] ), model.schema );
model.change( writer => {
writer.remove( Range.createIn( root ) );
writer.insert( parsed, root );
} );
expect( formatTable( getModelData( model, { withoutSelection: true } ) ) ).to.equal( formattedModelTable( [
[ '00', { rowspan: 2, contents: '10' }, '', '' ],
[ '10', { colspan: 2, contents: '12' } ],
[ '20', '21', '', '' ]
] ) );
} );
it( 'should fix multiple tables', () => {
const tableA = modelTable( [
[ '11' ],
[ '21', '22' ]
] );
const tableB = modelTable( [
[ 'aa', 'ab' ],
[ 'ba', 'bb' ]
] );
const tableC = modelTable( [
[ 'xx' ],
[ 'yy', 'yy' ]
] );
const parsed = parse( tableA + tableB + tableC, model.schema );
model.change( writer => {
writer.remove( Range.createIn( root ) );
writer.insert( parsed, root );
} );
const expectedTableA = formattedModelTable( [
[ '11', '' ],
[ '21', '22' ]
] );
const expectedTableB = formattedModelTable( [
[ 'aa', 'ab' ],
[ 'ba', 'bb' ]
] );
const expectedTableC = formattedModelTable( [
[ 'xx', '' ],
function _insertRow( writer, rowIndex, rowData ) {
const table = root.getChild( 0 );
const parsedTable = parse(
modelTable( [ rowData ] ),
model.schema
);
writer.insert( parsedTable.getChild( 0 ), table, rowIndex );
}