import { describe, it } 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'; describe('PasteColumnOperationsTest', () => { it('TBA: Test1', () => Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1X1H2
A2X2B2
A3X3B3
F1X4F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2X3X4', TableOperations.pasteColsAfter, 0, 0, 0 ) ); it('TBA: Test2', () => Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2X1
A2B2X2
A3B3X3
F1F2X4
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2X3X4', TableOperations.pasteColsAfter, 1, 1, 1 ) ); it('TBA: Test3', () => Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
X1H1H2
X2A2B2
X3A3B3
X4F1F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2X3X4', TableOperations.pasteColsBefore, 0, 0, 0 ) ); it('TBA: Test4', () => Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1X1H2
A2X2B2
A3X3B3
F1X4F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2X3X4', TableOperations.pasteColsBefore, 1, 1, 1 ) ); it('TBA: Test5', () => // Colspan Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1X1H2
A2X2Y2B2
A3X3Y3B3
F1X4Y4F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2Y2X3Y3X4Y4', TableOperations.pasteColsAfter, 0, 0, 0 ) ); it('TBA: Test6', () => // Rowspan Assertions.checkPaste( 'TBA', ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1X1H2
A2X2B2
A3B3
F1X4F2
' ), ( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
H1H2
A2B2
A3B3
F1F2
' ), 'X1X2X4', TableOperations.pasteColsBefore, 1, 0, 1 ) ); it('TBA: Test pasting cols (before) into table where num of rows in copied cols is less than number of rows in the table being pasted into', () => Assertions.checkPaste( 'Test pasting cols (before) into table where num of rows in copied cols is less than number of rows in the table being pasted into', generateTestTable( [ 'A2X1B2', 'A3?B3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 0 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0 ] } ), 'X1', TableOperations.pasteColsBefore, 0, 0, 1 ) ); it('TBA: Test pasting cols (after) into table where num of rows in copied cols is less than number of rows in the table being pasted into', () => Assertions.checkPaste( 'Test pasting cols (after) into table where num of rows in copied cols is less than number of rows in the table being pasted into', generateTestTable( [ 'A2X1B2', 'A3?B3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 2 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 1 ] } ), 'X1', TableOperations.pasteColsAfter, 0, 0, 0 ) ); it('TBA: Test pasting cols (before) into table where num of rows in copied cols is greater than number of rows in the table being pasted into', () => Assertions.checkPaste( 'Test pasting cols (before) into table where num of rows in copied cols is greater than number of rows in the table being pasted into', generateTestTable( [ 'X1A2B2', 'X2A3B3', 'X3??', 'X4??' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 2 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 1 ] } ), 'X1X2X3X4', TableOperations.pasteColsBefore, 0, 0, 0 ) ); it('TBA: Test pasting cols (after) into table where num of rows in copied cols is greater than number of rows in the table being pasted into', () => Assertions.checkPaste( 'Test pasting cols (after) into table where num of rows in copied cols is greater than number of rows in the table being pasted into', generateTestTable( [ 'A2B2X1', 'A3B3X2', '??X3', '??X4' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 0 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0 ] } ), 'X1X2X3X4', TableOperations.pasteColsAfter, 0, 0, 1 ) ); it('TINY-6765: Test that pasting cols (before) is a noop when the first column in the table is locked and selected', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (before) is a noop when the first column in the table is locked and selected', generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0 ] } ), 'X1X2', TableOperations.pasteColsBefore, 0, 0, 0 ) ); it('TINY-6765: Test that pasting cols (after) is not a noop when the first column in the table is locked and selected', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (after) is not a noop when the first column in the table is locked and selected', generateTestTable( [ 'A2X1B2', 'A3X2B3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 0 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 0 ] } ), 'X1X2', TableOperations.pasteColsAfter, 0, 0, 0 ) ); it('TINY-6765: Test that pasting cols (before) is not a noop when the last column in the table is locked and selected', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (before) is not a noop when the last column in the table is locked and selected', generateTestTable( [ 'A2X1B2', 'A3X2B3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 2 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 1 ] } ), 'X1X2', TableOperations.pasteColsBefore, 0, 0, 1 ) ); it('TINY-6765: Test that pasting cols (after) is a noop when the last column in the table is locked and selected', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (after) is a noop when the last column in the table is locked and selected', generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 1 ] } ), generateTestTable( [ 'A2B2', 'A3B3' ], [], [], { numCols: 2, colgroup: false, lockedColumns: [ 1 ] } ), 'X1X2', TableOperations.pasteColsAfter, 0, 0, 1 ) ); it('TINY-6765: Test that pasting cols (before) is not a noop when the selected locked column is not the first or last column', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (before) is not a noop when the selected locked column is not the first or last column', generateTestTable( [ 'A2X1B2C2', 'A3X2B3C3' ], [], [], { numCols: 4, colgroup: false, lockedColumns: [ 2 ] } ), generateTestTable( [ 'A2B2C2', 'A3B3C3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 1 ] } ), 'X1X2', TableOperations.pasteColsBefore, 0, 0, 1 ) ); it('TINY-6765: Test that pasting cols (after) is not a noop when the selected locked column is not the first or last column', () => Assertions.checkPaste( 'TINY-6765: Test that pasting cols (after) is not a noop when the selected locked column is not the first or last column', generateTestTable( [ 'A2B2X1C2', 'A3B3X2C3' ], [], [], { numCols: 4, colgroup: false, lockedColumns: [ 1 ] } ), generateTestTable( [ 'A2B2C2', 'A3B3C3' ], [], [], { numCols: 3, colgroup: false, lockedColumns: [ 1 ] } ), 'X1X2', TableOperations.pasteColsAfter, 0, 0, 1 ) ); it('TINY-8040: Paste a column into the middle of a large colspan, after version', () => Assertions.checkPaste( 'Paste a column into the middle of a large colspan', ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6XH7H8H9H0
A1A2??A3
' ), ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6H7H8H9H0
A1A2A3
' ), ( '' + 'X' + '' + '' ), TableOperations.pasteColsAfter, 0, 0, 5 ) ); it('TINY-8040: Paste a column into the middle of a large colspan, before version', () => Assertions.checkPaste( 'Paste a column into the middle of a large colspan', ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5XH6H7H8H9H0
A1A2??A3
' ), ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6H7H8H9H0
A1A2A3
' ), ( '' + 'X' + '' + '' ), TableOperations.pasteColsBefore, 0, 0, 5 ) ); it('TINY-8040: Paste a column into the middle of a large colspan with no cell at the end', () => Assertions.checkPaste( 'Paste a column into the middle of a large colspan', ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5XH6H7H8H9H0
A1A2??
' ), ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6H7H8H9H0
A1A2
' ), ( '' + 'X' + '' + '' ), TableOperations.pasteColsBefore, 0, 0, 5 ) ); it('TINY-8040: Paste a column into the middle of a large colspan with no cell at the start', () => Assertions.checkPaste( 'Paste a column into the middle of a large colspan', ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5XH6H7H8H9H0
A2??A3
' ), ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6H7H8H9H0
A2A3
' ), ( '' + 'X' + '' + '' ), TableOperations.pasteColsBefore, 0, 0, 5 ) ); it('TINY-8040: Paste a column into the middle of a large colspan with no cell at the start or end', () => Assertions.checkPaste( 'Paste a column into the middle of a large colspan', ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5XH6H7H8H9H0
A2??
' ), ( '' + '' + '' + '' + '' + '' + '' + '
H1H2H3H4H5H6H7H8H9H0
A2
' ), ( '' + 'X' + '' + '' ), TableOperations.pasteColsBefore, 0, 0, 5 ) ); /* TINY-6910 TODO: Need a way to test multi-cell selections - will require something like Asserstions.pasteMultiple or Assertions.checkPaste should be changed to take an array TODO: Test colgroup tables with locked column not around selection */ });