import { UnitTest } from '@ephox/bedrock-client';
import * as Assertions from 'ephox/snooker/test/Assertions';
UnitTest.test('UnmergeOperationsTest', () => {
Assertions.checkUnmerge(
'TBA',
'
' +
'| A1 | B1 | C1 | D1 |
' +
'| ? | B2 | C2 | D2 |
' +
'| ? | B3 | C3 | D3 |
' +
'
',
'' +
'| A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TBA',
'' +
'| ' +
'' +
'A1 | B1 | C1 | D1 |
' +
'| ? | B2 | C2 | D2 |
' +
'| ? | B3 | C3 | D3 |
' +
'
',
'' +
'| ' +
'' +
'A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TBA',
'' +
'| A1 | B1 | C1 |
' +
'| B2 | C2 | ? |
' +
'| B3 | ? | ? |
' +
'
',
'' +
'| A1 | B1 | C1 |
' +
'| B2 | C2 |
' +
'| B3 |
' +
'
',
[
{ section: 0, row: 1, column: 1 }
]
);
Assertions.checkUnmerge(
'TBA',
'' +
'| A1 | ? | ? | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'| A3 | B3 | C3 | D3 |
' +
'
',
'' +
'| A1 | D1 |
' +
'' +
'' +
'| A2 | B2 | C2 | D2 |
' +
'| A3 | B3 | C3 | D3 |
' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TBA',
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | ? | ? | D2 |
' +
'| A3 | B3 | C3 | D3 |
' +
'
',
'' +
'| A1 | B1 | C1 | D1 |
' +
'' +
'' +
'| A2 | D2 |
' +
'| A3 | B3 | C3 | D3 |
' +
'
',
[
{ section: 1, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TINY-6484: rowgroup-scoped cell split into cells results in all generated spells having scope row',
'' +
'' +
'' +
'| A1 | ' +
'B1 | ' +
'C1 | ' +
'D1 | ' +
'
' +
'' +
'| ? | ' +
'B2 | ' +
'C2 | ' +
'D2 | ' +
'
' +
'' +
'| ? | ' +
'B3 | ' +
'C3 | ' +
'D3 | ' +
'
' +
'' +
'
',
'' +
'' +
'' +
'| A1 | ' +
'B1 | ' +
'C1 | ' +
'D1 | ' +
'
' +
'' +
'| B2 | ' +
'C2 | ' +
'D2 | ' +
'
' +
'' +
'| B3 | ' +
'C3 | ' +
'D3 | ' +
'
' +
'' +
'
',
[
{
section: 0,
row: 0,
column: 0
}
]
);
Assertions.checkUnmerge(
'TINY-6484: colgroup-scoped cell split into cells results in all generated spells having scope col',
'' +
'' +
'' +
'| A1 | ' +
'? | ' +
'? | ' +
'? | ' +
'
' +
'' +
'| A2 | ' +
'B2 | ' +
'C2 | ' +
'D2 | ' +
'
' +
'' +
'| A3 | ' +
'B3 | ' +
'C3 | ' +
'D3 | ' +
'
' +
'' +
'
',
'' +
'' +
'' +
'| A1 | ' +
'
' +
'' +
'| A2 | ' +
'B2 | ' +
'C2 | ' +
'D2 | ' +
'
' +
'' +
'| A3 | ' +
'B3 | ' +
'C3 | ' +
'D3 | ' +
'
' +
'' +
'
',
[
{
section: 0,
row: 0,
column: 0
}
]
);
Assertions.checkUnmerge(
'TINY-6765 - unmerging rowpsan cells with locked column in selection should be noop',
'' +
'| A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
'' +
'| A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TINY-6765 - unmerging rowspan cells with a locked column in the table but not selected should not affect unmerging',
'' +
'| A1 | B1 | C1 | D1 |
' +
'| ? | B2 | C2 | D2 |
' +
'| ? | B3 | C3 | D3 |
' +
'
',
'' +
'| A1 | B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'| B3 | C3 | D3 |
' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TINY-6765 - unmerging colspan cells where the first cell of the colspan is part of a locked column should be a noop',
'' +
'' +
'| A1 |
' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'' +
'
',
'' +
'' +
'| A1 |
' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
Assertions.checkUnmerge(
'TINY-6765 - unmerging colspan cells where the first cell of the colspan is not part of a locked column should not affect unmerging',
'' +
'' +
'| A1 | ? | ? |
' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'' +
'
',
'' +
'' +
'| A1 |
' +
'| B1 | C1 | D1 |
' +
'| B2 | C2 | D2 |
' +
'' +
'
',
[
{ section: 0, row: 0, column: 0 }
]
);
});