|
|
@@ -80,7 +80,7 @@ describe( 'SelectColumnCommand', () => {
|
|
|
] );
|
|
|
} );
|
|
|
|
|
|
- it( 'should select a given column from a table start', () => {
|
|
|
+ it( 'should select a column of table cell with a collapsed selection in first table cell', () => {
|
|
|
setData( model, modelTable( [
|
|
|
[ '[]00', '01' ],
|
|
|
[ '10', '11' ],
|
|
|
@@ -96,7 +96,7 @@ describe( 'SelectColumnCommand', () => {
|
|
|
] );
|
|
|
} );
|
|
|
|
|
|
- it( 'should select a given column from a table start when selection is at the end', () => {
|
|
|
+ it( 'should select a column of table cell with a collapsed selection in last cell in the first column', () => {
|
|
|
setData( model, modelTable( [
|
|
|
[ '00', '01' ],
|
|
|
[ '10', '11' ],
|
|
|
@@ -112,7 +112,7 @@ describe( 'SelectColumnCommand', () => {
|
|
|
] );
|
|
|
} );
|
|
|
|
|
|
- it( 'should select last column', () => {
|
|
|
+ it( 'should select a column of table cell with collapsed selection in the first cell of the last column', () => {
|
|
|
setData( model, modelTable( [
|
|
|
[ '00', '01[]' ],
|
|
|
[ '10', '11' ]
|
|
|
@@ -126,47 +126,189 @@ describe( 'SelectColumnCommand', () => {
|
|
|
] );
|
|
|
} );
|
|
|
|
|
|
- it( 'should select col-spanned cells', () => {
|
|
|
- // +----+----+----+----+
|
|
|
- // | 00 |
|
|
|
- // +----+----+----+----+
|
|
|
- // | 10 | 13 |
|
|
|
- // +----+----+----+----+
|
|
|
- // | 20 | 22 | 23 |
|
|
|
- // +----+----+----+----+
|
|
|
- // | 30 | 31 | 33 |
|
|
|
- // +----+----+----+----+
|
|
|
- // | 40 | 41 | 42 | 43 |
|
|
|
- // +----+----+----+----+
|
|
|
- setData( model, modelTable( [
|
|
|
- [ { colspan: 4, contents: '00' } ],
|
|
|
- [ { colspan: 3, contents: '10' }, '13' ],
|
|
|
- [ { colspan: 2, contents: '20' }, '22', '23' ],
|
|
|
- [ '30', { colspan: 2, contents: '31' }, '33' ],
|
|
|
- [ '40', '41[]', '42', '43' ]
|
|
|
- ] ) );
|
|
|
+ describe( 'with col-spanned cells', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 00 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 10 | 13 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 20 | 22 | 23 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 30 | 31 | 33 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ // | 40 | 41 | 42 | 43 |
|
|
|
+ // +----+----+----+----+
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { colspan: 4, contents: '00' } ],
|
|
|
+ [ { colspan: 3, contents: '10' }, '13' ],
|
|
|
+ [ { colspan: 2, contents: '20' }, '22', '23' ],
|
|
|
+ [ '30', { colspan: 2, contents: '31' }, '33' ],
|
|
|
+ [ '40', '41', '42', '43' ]
|
|
|
+ ] ) );
|
|
|
+ } );
|
|
|
|
|
|
- command.execute();
|
|
|
+ it( 'should select only one column if only one cell is selected', () => {
|
|
|
+ // Selection in cell 10.
|
|
|
+ tableSelection._setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 1, 0 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 1, 0 ] )
|
|
|
+ );
|
|
|
|
|
|
- /* eslint-disable no-multi-spaces */
|
|
|
- assertSelectedCells( model, [
|
|
|
- [ 0 ],
|
|
|
- [ 0, 0 ],
|
|
|
- [ 0, 0, 0 ],
|
|
|
- [ 0, 1, 0 ],
|
|
|
- [ 0, 1, 0, 0 ]
|
|
|
- ] );
|
|
|
- /* eslint-enable no-multi-spaces */
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 1, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 1 ],
|
|
|
+ [ 1, 0 ],
|
|
|
+ [ 1, 0, 0 ],
|
|
|
+ [ 1, 0, 0 ],
|
|
|
+ [ 1, 0, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should not select col-spanned columns that start in other column', () => {
|
|
|
+ // Selection in cell 42.
|
|
|
+ tableSelection._setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 2 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 2 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 1, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 1, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 1, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should not select col-spanned columns that start in other column but include those that start in selected column', () => {
|
|
|
+ // Selection in cell 41.
|
|
|
+ tableSelection._setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 1 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 1 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 1, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 1, 0 ],
|
|
|
+ [ 0, 1, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should select properly for multiple not spanned cells selected', () => {
|
|
|
+ // Selection in cells 40 - 41.
|
|
|
+ tableSelection._setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 0 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 4, 1 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 1, 1, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 1 ],
|
|
|
+ [ 1, 0 ],
|
|
|
+ [ 1, 0, 0 ],
|
|
|
+ [ 1, 1, 0 ],
|
|
|
+ [ 1, 1, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should select properly for multiple cells selected including spanned one', () => {
|
|
|
+ // Selection in cells 31 - 33.
|
|
|
+ tableSelection._setCellSelection(
|
|
|
+ modelRoot.getNodeByPath( [ 0, 3, 1 ] ),
|
|
|
+ modelRoot.getNodeByPath( [ 0, 3, 2 ] )
|
|
|
+ );
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 0 ],
|
|
|
+ [ 0, 0, 0 ],
|
|
|
+ [ 0, 1, 1 ],
|
|
|
+ [ 0, 0, 0, 0 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ /* eslint-disable no-multi-spaces */
|
|
|
+ assertSelectedCells( model, [
|
|
|
+ [ 0 ],
|
|
|
+ [ 0, 1 ],
|
|
|
+ [ 0, 1, 1 ],
|
|
|
+ [ 0, 1, 1 ],
|
|
|
+ [ 0, 1, 1, 1 ]
|
|
|
+ ] );
|
|
|
+ /* eslint-enable no-multi-spaces */
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'with multiple columns selected', () => {
|
|
|
- it( 'should properly select middle columns', () => {
|
|
|
+ beforeEach( () => {
|
|
|
setData( model, modelTable( [
|
|
|
[ '00', '01', '02', '03' ],
|
|
|
[ '10', '11', '12', '13' ],
|
|
|
[ '20', '21', '22', '23' ]
|
|
|
] ) );
|
|
|
+ } );
|
|
|
|
|
|
+ it( 'should properly select middle columns', () => {
|
|
|
tableSelection._setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 1 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 2 ] )
|
|
|
@@ -182,12 +324,6 @@ describe( 'SelectColumnCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should properly select middle columns in reversed order', () => {
|
|
|
- setData( model, modelTable( [
|
|
|
- [ '00', '01', '02', '03' ],
|
|
|
- [ '10', '11', '12', '13' ],
|
|
|
- [ '20', '21', '22', '23' ]
|
|
|
- ] ) );
|
|
|
-
|
|
|
tableSelection._setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 2 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 1 ] )
|
|
|
@@ -203,12 +339,6 @@ describe( 'SelectColumnCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should properly select tailing columns', () => {
|
|
|
- setData( model, modelTable( [
|
|
|
- [ '00', '01', '02', '03' ],
|
|
|
- [ '10', '11', '12', '13' ],
|
|
|
- [ '20', '21', '22', '23' ]
|
|
|
- ] ) );
|
|
|
-
|
|
|
tableSelection._setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 2 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 3 ] )
|
|
|
@@ -224,12 +354,6 @@ describe( 'SelectColumnCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should properly select beginning columns', () => {
|
|
|
- setData( model, modelTable( [
|
|
|
- [ '00', '01', '02', '03' ],
|
|
|
- [ '10', '11', '12', '13' ],
|
|
|
- [ '20', '21', '22', '23' ]
|
|
|
- ] ) );
|
|
|
-
|
|
|
tableSelection._setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 0 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 1 ] )
|
|
|
@@ -245,12 +369,6 @@ describe( 'SelectColumnCommand', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should properly select multiple columns from square selection', () => {
|
|
|
- setData( model, modelTable( [
|
|
|
- [ '00', '01', '02' ],
|
|
|
- [ '10', '11', '12' ],
|
|
|
- [ '20', '21', '22' ]
|
|
|
- ] ) );
|
|
|
-
|
|
|
tableSelection._setCellSelection(
|
|
|
modelRoot.getNodeByPath( [ 0, 0, 1 ] ),
|
|
|
modelRoot.getNodeByPath( [ 0, 1, 2 ] )
|
|
|
@@ -259,9 +377,9 @@ describe( 'SelectColumnCommand', () => {
|
|
|
command.execute();
|
|
|
|
|
|
assertSelectedCells( model, [
|
|
|
- [ 0, 1, 1 ],
|
|
|
- [ 0, 1, 1 ],
|
|
|
- [ 0, 1, 1 ]
|
|
|
+ [ 0, 1, 1, 0 ],
|
|
|
+ [ 0, 1, 1, 0 ],
|
|
|
+ [ 0, 1, 1, 0 ]
|
|
|
] );
|
|
|
} );
|
|
|
|