|
|
@@ -163,7 +163,7 @@ describe( 'MergeCellCommand', () => {
|
|
|
command.execute();
|
|
|
|
|
|
expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
|
|
|
- [ { colspan: 2, contents: '[]0001' } ]
|
|
|
+ [ { colspan: 2, contents: '[0001]' } ]
|
|
|
] ) );
|
|
|
} );
|
|
|
} );
|
|
|
@@ -263,7 +263,7 @@ describe( 'MergeCellCommand', () => {
|
|
|
command.execute();
|
|
|
|
|
|
expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
|
|
|
- [ { colspan: 2, contents: '00[]01' } ]
|
|
|
+ [ { colspan: 2, contents: '[0001]' } ]
|
|
|
] ) );
|
|
|
} );
|
|
|
} );
|
|
|
@@ -372,7 +372,117 @@ describe( 'MergeCellCommand', () => {
|
|
|
command.execute();
|
|
|
|
|
|
expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
|
|
|
- [ '00', { rowspan: 2, contents: '0111[]' } ],
|
|
|
+ [ '00', { rowspan: 2, contents: '[0111]' } ],
|
|
|
+ [ '10' ]
|
|
|
+ ] ) );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'direction=up', () => {
|
|
|
+ beforeEach( () => {
|
|
|
+ command = new MergeCellCommand( editor, { direction: 'up' } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'isEnabled', () => {
|
|
|
+ it( 'should be true if in cell that has mergeable cell in previous row', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00', '01' ],
|
|
|
+ [ '10', '11[]' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be false if in first row', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00[]', '01' ],
|
|
|
+ [ '10', '11' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be true if in a cell that has mergeable cell with the same colspan', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { colspan: 2, contents: '00' }, '02' ],
|
|
|
+ [ { colspan: 2, contents: '01[]' }, '12' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be false if in a cell that potential mergeable cell has different colspan', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { colspan: 2, contents: '00' }, '02' ],
|
|
|
+ [ { colspan: 3, contents: '01[]' } ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be false if not in a cell', () => {
|
|
|
+ setData( model, '<p>11[]</p>' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'value', () => {
|
|
|
+ it( 'should be set to mergeable cell', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00', '01' ],
|
|
|
+ [ '10', '11[]' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 1 ] ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be undefined if in first row', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00[]', '01' ],
|
|
|
+ [ '10', '11' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be set to mergeable cell with the same rowspan', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { colspan: 2, contents: '00' }, '02' ],
|
|
|
+ [ { colspan: 2, contents: '01[]' }, '12' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be undefined if in a cell that potential mergeable cell has different rowspan', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ { colspan: 2, contents: '00' }, '02' ],
|
|
|
+ [ { colspan: 3, contents: '01[]' } ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should be undefined if not in a cell', () => {
|
|
|
+ setData( model, '<p>11[]</p>' );
|
|
|
+
|
|
|
+ expect( command.value ).to.be.undefined;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ describe( 'execute()', () => {
|
|
|
+ it( 'should merge table cells ', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00', '01' ],
|
|
|
+ [ '10', '11[]' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ command.execute();
|
|
|
+
|
|
|
+ expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
|
|
|
+ [ '00', { rowspan: 2, contents: '[0111]' } ],
|
|
|
[ '10' ]
|
|
|
] ) );
|
|
|
} );
|