import { UnitTest } from '@ephox/bedrock-client';
import { Optional } from '@ephox/katamari';
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('EraseOperationsTest', () => {
const deleteExpected1 = '
' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 0 }),
Optional.some(deleteExpected1),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 1, column: 0 }
]
);
const deleteExpected2 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected2),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 0 },
{ section: 0, row: 0, column: 1 }
]
);
const deleteExpected3 = '' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 0 }),
Optional.some(deleteExpected3),
'' +
'| ' +
'' +
'A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 1, column: 0 }
]
);
const deleteExpected4 = '' +
'| A1 | D1 |
' +
'| A2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 1 }),
Optional.some(deleteExpected4),
'' +
'| A1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 1, column: 1 }
]
);
const deleteExpected5 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected5),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected6 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected6),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'| A3 | B3 | C3 | D3 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 },
{ section: 0, row: 1, column: 0 }
]
);
const deleteExpected7 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected7),
'' +
'| ' +
'' +
'A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected8 = '' +
'| A1 | B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected8),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected9 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected9),
'',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 },
{ section: 0, row: 1, column: 2 }
]
);
const deleteExpected10 = '' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 50 | 51 | 52 | 33 34 43 44 53 54 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 2 }),
Optional.some(deleteExpected10),
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 1, column: 2 },
{ section: 0, row: 3, column: 2 },
{ section: 0, row: 4, column: 2 }
]
);
const deleteExpected11 = '' +
'' +
'| 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 1 }),
Optional.some(deleteExpected11),
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 1, column: 1 },
{ section: 0, row: 3, column: 1 },
{ section: 0, row: 4, column: 1 }
]
);
const deleteExpected12 =
'' +
'| 0 | 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 3, column: 3 }),
Optional.some(deleteExpected12),
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 3, column: 3 }
]
);
const deleteExpected13 =
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 40 | 41 | 42 | 33 34 43 44 53 54 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 3, column: 3 }),
Optional.some(deleteExpected13),
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 3, column: 3 }
]
);
const deleteExpected14 = '' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 4, column: 7 }),
Optional.some(deleteExpected14),
'' +
'| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
' +
'| 10 | 11 21 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
' +
'| 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
' +
'| 30 | 31 | 32 | 33 34 43 44 53 54 | 35 | 36 | 37 | 38 | 39 |
' +
'| 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 |
' +
'| 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 |
' +
'| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
' +
'| 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
' +
'| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
' +
'| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 4, column: 5 },
{ section: 0, row: 5, column: 5 }
]
);
const deleteExpected15 =
'' +
'| row 0 cell 0 row 1 cell 0 | row 1 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 1 }),
Optional.some(deleteExpected15),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 1 }
]
);
const deleteExpected16 =
'' +
'| row 2 cell 0 | row 2 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 1 }),
Optional.some(deleteExpected16),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 1 },
{ section: 0, row: 1, column: 0 } // Note: this one is 0 because hierarchy doesn't account for merged cells, here we are actually targeting cell 1,1 but in the dom structure is in position 0
]
);
const deleteExpected17 =
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'
' +
'| row 2 cell 0 |
' +
'| row 3 cell 0 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 1 }),
Optional.some(deleteExpected17),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 1 },
{ section: 0, row: 1, column: 0 } // Note: this one is 0 because hierarchy doesn't account for merged cells, here we are actually targeting cell 1,1 but in the dom structure is in position 0
]
);
const deleteExpected18 =
'' +
'| row 0 cell 0 row 1 cell 0 |
' +
'
' +
'| row 2 cell 0 |
' +
'| row 3 cell 0 |
' +
'| row 4 cell 0 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 2, column: 0 }),
Optional.some(deleteExpected18),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 2 },
{ section: 0, row: 2, column: 1 },
{ section: 0, row: 3, column: 1 },
{ section: 0, row: 3, column: 2 },
{ section: 0, row: 4, column: 1 },
{ section: 0, row: 4, column: 2 }
]
);
Assertions.checkDelete(
'TBA',
Optional.none(),
Optional.none(),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 2 },
{ section: 0, row: 2, column: 1 },
{ section: 0, row: 3, column: 1 },
{ section: 0, row: 3, column: 2 },
{ section: 0, row: 4, column: 1 },
{ section: 0, row: 4, column: 2 }
]
);
Assertions.checkDelete(
'TBA',
Optional.none(),
Optional.none(),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 4, column: 0 },
{ section: 0, row: 4, column: 1 },
{ section: 0, row: 4, column: 2 }
]
);
const deleteExpected19 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected19),
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected20 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected20),
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 1, row: 0, column: 0 }
]
);
Assertions.checkDelete(
'TBA',
Optional.none(),
Optional.none(),
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 },
{ section: 1, row: 0, column: 0 }
]
);
const deleteExpected21 = '' +
'| B1 | C1 | D1 |
' +
'' +
'' +
'| B2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected21),
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected22 = '' +
'| B1 | C1 | D1 |
' +
'' +
'' +
'| B2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected22),
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 0 },
{ section: 1, row: 0, column: 0 }
]
);
const deleteExpected23 = '' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'
';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 1, column: 0 }),
Optional.some(deleteExpected23),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 1, column: 0 }
]
);
const deleteExpected24 = '';
Assertions.checkDelete(
'TBA',
Optional.some({ section: 0, row: 0, column: 0 }),
Optional.some(deleteExpected24),
'' +
'| A1 | B1 | C1 | D1 |
' +
'| A2 | B2 | C2 | D2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 0, column: 0 }
]
);
const deleteExpected25 = generateTestTable(
[ '| B2 | C2 | D2 |
' ],
[], [],
{ numCols: 3, colgroup: true, lockedColumns: [] }
);
Assertions.checkDelete(
'Check that columns in a colgroup table can be erased',
Optional.some({ section: 1, row: 0, column: 0 }),
Optional.some(deleteExpected25),
generateTestTable(
[ '| A2 | B2 | C2 | D2 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [] }
),
TableOperations.eraseColumns,
[
{ section: 1, row: 0, column: 0 }
]
);
const deleteExpected26 = generateTestTable(
[ '| A3 | B3 | C3 | D3 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [] }
);
Assertions.checkDelete(
'Check that rows in a colgroup table can be erased',
Optional.some({ section: 1, row: 0, column: 0 }),
Optional.some(deleteExpected26),
generateTestTable(
[ '| A2 | B2 | C2 | D2 |
', '| A3 | B3 | C3 | D3 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [] }
),
TableOperations.eraseRows,
[
{ section: 1, row: 0, column: 0 }
]
);
const deleteExpected27 = generateTestTable(
[ '| A2 | B2 | C2 | D2 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [ 0 ] }
);
Assertions.checkDelete(
'TINY-6765: Check that selected locked column cannot be erased',
Optional.none(),
Optional.some(deleteExpected27),
generateTestTable(
[ '| A2 | B2 | C2 | D2 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [ 0 ] }
),
TableOperations.eraseColumns,
[
{ section: 1, row: 0, column: 0 }
]
);
const deleteExpected28 = generateTestTable(
[ '| A2 | B2 | C2 | D2 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [ 0 ] }
);
Assertions.checkDelete(
'TINY-6765: Check that locked columns does not affect erasing rows',
Optional.none(),
Optional.some(deleteExpected28),
generateTestTable(
[
'| A2 | B2 | C2 | D2 |
',
'| A3 | B3 | C3 | D3 |
'
],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [ 0 ] }
),
TableOperations.eraseRows,
[
{ section: 1, row: 1, column: 1 }
]
);
const deleteExpected29 = generateTestTable(
[ '| A2 | C2 |
' ],
[], [],
{ numCols: 2, colgroup: true, lockedColumns: [ 0, 1 ] }
);
Assertions.checkDelete(
'TINY-6765: Check that for a multi-column selection, non-locked columns are erased and locked columns are kept',
Optional.none(),
Optional.some(deleteExpected29),
generateTestTable(
[ '| A2 | B2 | C2 | D2 |
' ],
[], [],
{ numCols: 4, colgroup: true, lockedColumns: [ 0, 2 ] }
),
TableOperations.eraseColumns,
[
{ section: 1, row: 0, column: 0 },
{ section: 1, row: 0, column: 1 },
{ section: 1, row: 0, column: 2 },
{ section: 1, row: 0, column: 3 },
]
);
const deleteExpected30 =
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'
';
Assertions.checkDelete(
'TINY-7695: Deleting the last 2 rows should keep the cursor in the last row',
Optional.some({ section: 0, row: 2, column: 1 }),
Optional.some(deleteExpected30),
'' +
'| row 0 cell 0 row 1 cell 0 | row 0 cell 1 | row 0 cell 2 row 1 cell 2 row 2 cell 2 |
' +
'| row 1 cell 1 |
' +
'| row 2 cell 0 | row 2 cell 1 |
' +
'| row 3 cell 0 | row 3 cell 1 | row 3 cell 2 |
' +
'| row 4 cell 0 | row 4 cell 1 | row 4 cell 2 |
' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 3, column: 1 },
{ section: 0, row: 3, column: 2 },
{ section: 0, row: 4, column: 1 },
{ section: 0, row: 4, column: 2 },
]
);
const deleteExpected31 = '';
Assertions.checkDelete(
'TINY-7695: Deleting the last row should not move the selection into a cef element',
Optional.some({ section: 0, row: 0, column: 1 }),
Optional.some(deleteExpected31),
'' +
'' +
'| A1 | B1 |
' +
'| A2 | B2 |
' +
'' +
'
',
TableOperations.eraseRows,
[
{ section: 0, row: 1, column: 0 },
{ section: 0, row: 1, column: 1 }
]
);
const deleteExpected32 = '' +
'' +
'| A1 |
' +
'| A2 |
' +
'' +
'
';
Assertions.checkDelete(
'TINY-7695: Deleting the last column should not move the selection into a cef element',
Optional.some({ section: 0, row: 1, column: 0 }),
Optional.some(deleteExpected32),
'' +
'' +
'| A1 | B1 |
' +
'| A2 | B2 |
' +
'' +
'
',
TableOperations.eraseColumns,
[
{ section: 0, row: 0, column: 1 },
{ section: 0, row: 1, column: 1 }
]
);
});