import { UnitTest } from '@ephox/bedrock-client'; import * as TableOperations from 'ephox/snooker/api/TableOperations'; import * as Assertions from 'ephox/snooker/test/Assertions'; import { generateTestTable } from 'ephox/snooker/test/CreateTableUtils'; UnitTest.test('PasteRowOperationsTest', () => { Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
X1X2
A2B2
A3B3
F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsAfter, 0, 0, 0 ); Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
X1X2
F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsAfter, 1, 1, 0 ); Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
X1X2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsAfter, 2, 0, 0 ); Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
X1X2
H1H1
A2B2
A3B3
F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsBefore, 0, 0, 0 ); Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
X1X2
A3B3
F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsBefore, 1, 1, 0 ); Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
X1X2
F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H1
A2B2
A3B3
F1F2
' ), 'X1X2', TableOperations.pasteRowsBefore, 2, 0, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (before) into table where num of cols in copied rows is less than number of cols in the table being pasted into', generateTestTable( [ 'X1?', 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), 'X1', TableOperations.pasteRowsBefore, 0, 0, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (after) into table where num of cols in copied rows is less than number of cols in the table being pasted into', generateTestTable( [ 'A2B2', 'X1?', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), 'X1', TableOperations.pasteRowsAfter, 0, 0, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (before) into table where num of cols in copied rows is greater than number of cols in the table being pasted into', generateTestTable( [ 'X1X2X3X4', 'A2B2??', 'A3B3??' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), 'X1X2X3X4', TableOperations.pasteRowsBefore, 0, 0, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (after) into table where num of cols in copied rows is greater than number of cols in the table being pasted into', generateTestTable( [ 'A2B2??', 'A3B3??', 'X1X2X3X4' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [] } ), 'X1X2X3X4', TableOperations.pasteRowsAfter, 0, 1, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (before) into table where there are locked columns - should wrap around locked columns (last locked column should remain as last column)', generateTestTable( [ 'A2B2?C2', '?X1X2?', 'A3B3?C3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 3 ] } ), generateTestTable( [ 'A2B2C2', 'A3B3C3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 2 ] } ), 'X1X2', TableOperations.pasteRowsBefore, 0, 1, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (after) into table where there are locked columns - should wrap around locked columns (last locked column should remain as last column)', generateTestTable( [ 'A2B2?C2', 'A3B3?C3', '?X1X2?' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 3 ] } ), generateTestTable( [ 'A2B2C2', 'A3B3C3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 2 ] } ), 'X1X2', TableOperations.pasteRowsAfter, 0, 1, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (after) into table where all columns are locked - (first and last locked column should remain as first and last column)', generateTestTable( [ 'A2??B2', '?X1X2?', 'A3??B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 3 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0, 1 ] } ), 'X1X2', TableOperations.pasteRowsAfter, 0, 0, 0 ); Assertions.checkPaste( 'TINY-6765: Test pasting rows (before) with less cols into table where there are locked columns', generateTestTable( [ 'A2B2C2', 'X1X2?', 'A3B3C3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 2 ] } ), generateTestTable( [ 'A2B2C2', 'A3B3C3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 2 ] } ), 'X1X2', TableOperations.pasteRowsBefore, 0, 1, 0 ); });