|
|
@@ -18,7 +18,6 @@ import MarkerOperation from '../../../src/model/operation/markeroperation';
|
|
|
import MoveOperation from '../../../src/model/operation/moveoperation';
|
|
|
import RemoveOperation from '../../../src/model/operation/removeoperation';
|
|
|
import RenameOperation from '../../../src/model/operation/renameoperation';
|
|
|
-import ReinsertOperation from '../../../src/model/operation/reinsertoperation';
|
|
|
import NoOperation from '../../../src/model/operation/nooperation';
|
|
|
|
|
|
describe( 'transform', () => {
|
|
|
@@ -122,7 +121,34 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( transformBy, true );
|
|
|
+ const transOp = transform( transformBy, { isStrong: true } );
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'target at same offset and context.insertBefore = true: no position update', () => {
|
|
|
+ const transformBy = new InsertOperation(
|
|
|
+ new Position( root, [ 0, 2, 2 ] ),
|
|
|
+ [ nodeC, nodeD ],
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+
|
|
|
+ const transOp = transform( transformBy, { isStrong: false, insertBefore: false } );
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'target at same offset and context.insertBefore = false: increment offset', () => {
|
|
|
+ const transformBy = new InsertOperation(
|
|
|
+ new Position( root, [ 0, 2, 2 ] ),
|
|
|
+ [ nodeC, nodeD ],
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+
|
|
|
+ const transOp = transform( op, transformBy );
|
|
|
+ expected.position.offset += 2;
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -299,7 +325,36 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'target offset same as insert position offset and context.insertBefore = true: increment offset', () => {
|
|
|
+ const transformBy = new MoveOperation(
|
|
|
+ new Position( root, [ 1, 1 ] ),
|
|
|
+ 2,
|
|
|
+ new Position( root, [ 0, 2, 2 ] ),
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true, insertBefore: true } );
|
|
|
+ expected.position.offset += 2;
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'target offset same as insert position offset and context.insertBefore = false: no position update', () => {
|
|
|
+ const transformBy = new MoveOperation(
|
|
|
+ new Position( root, [ 1, 1 ] ),
|
|
|
+ 2,
|
|
|
+ new Position( root, [ 0, 2, 2 ] ),
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: false, insertBefore: false } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -610,7 +665,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expected.oldValue = null;
|
|
|
|
|
|
@@ -626,7 +681,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -641,7 +696,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expected.oldValue = null;
|
|
|
|
|
|
@@ -664,7 +719,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -690,7 +745,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -715,7 +770,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 3 );
|
|
|
|
|
|
@@ -1410,33 +1465,35 @@ describe( 'transform', () => {
|
|
|
expected.range = new Range( start, end );
|
|
|
} );
|
|
|
|
|
|
- it( 'remove operation inserted holder element before attribute operation range: increment path', () => {
|
|
|
+ it( 'remove operation inserted elements before attribute operation range: increment path', () => {
|
|
|
const transformBy = new RemoveOperation(
|
|
|
new Position( root, [ 0 ] ),
|
|
|
2,
|
|
|
+ new Position( doc.graveyard, [ 0 ] ),
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- transformBy.targetPosition.path = [ 0, 0 ];
|
|
|
+ transformBy.targetPosition.path = [ 0 ];
|
|
|
|
|
|
const transOp = transform( op, transformBy );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
- expected.range.start.path = [ 3, 0 ];
|
|
|
- expected.range.end.path = [ 3, 4 ];
|
|
|
+ expected.range.start.path = [ 4, 0 ];
|
|
|
+ expected.range.end.path = [ 4, 4 ];
|
|
|
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
} );
|
|
|
|
|
|
- it( 'remove operation inserted holder element after attribute operation range: do nothing', () => {
|
|
|
+ it( 'remove operation inserted elements after attribute operation range: do nothing', () => {
|
|
|
const transformBy = new RemoveOperation(
|
|
|
new Position( root, [ 0 ] ),
|
|
|
2,
|
|
|
+ new Position( doc.graveyard, [ 0 ] ),
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- transformBy.targetPosition.path = [ 4, 0 ];
|
|
|
+ transformBy.targetPosition.path = [ 4 ];
|
|
|
|
|
|
const transOp = transform( op, transformBy );
|
|
|
|
|
|
@@ -1573,7 +1630,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -1766,7 +1823,7 @@ describe( 'transform', () => {
|
|
|
|
|
|
it( 'target before node from move target position path: increment index on move target position path', () => {
|
|
|
const transformBy = new InsertOperation(
|
|
|
- new Position( root, [ 3, 0 ] ),
|
|
|
+ new Position( root, [ 3, 3 ] ),
|
|
|
[ nodeA, nodeB ],
|
|
|
baseVersion
|
|
|
);
|
|
|
@@ -1814,22 +1871,35 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
} );
|
|
|
|
|
|
- it( 'target offset same as move target offset: increment target offset', () => {
|
|
|
+ it( 'target offset same as move target offset and context.insertBefore = true: increment target offset', () => {
|
|
|
const transformBy = new InsertOperation(
|
|
|
- new Position( root, [ 3, 3 ] ),
|
|
|
+ new Position( root, [ 3, 3, 3 ] ),
|
|
|
[ nodeA, nodeB ],
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true, insertBefore: true } );
|
|
|
|
|
|
- expected.targetPosition.path[ 1 ] += 2;
|
|
|
+ expected.targetPosition.offset += 2;
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'target offset same as move target offset and context.insertBefore = false: no operation update', () => {
|
|
|
+ const transformBy = new InsertOperation(
|
|
|
+ new Position( root, [ 3, 3, 3 ] ),
|
|
|
+ [ nodeA, nodeB ],
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: false, insertBefore: false } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -1985,7 +2055,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
@@ -2347,7 +2417,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expected.sourcePosition.path = [ 4, 1, 0 ];
|
|
|
|
|
|
@@ -2380,7 +2450,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expected.sourcePosition.path = [ 4, 1, 1 ];
|
|
|
|
|
|
@@ -2418,7 +2488,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
@@ -2456,7 +2526,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -2495,7 +2565,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -2540,7 +2610,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
@@ -2574,7 +2644,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -2599,7 +2669,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
@@ -2638,7 +2708,7 @@ describe( 'transform', () => {
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
} );
|
|
|
|
|
|
- it( 'range inside transforming range and is important: shrink range', () => {
|
|
|
+ it( 'range inside transforming range and is important: split into two operations', () => {
|
|
|
op.howMany = 4;
|
|
|
|
|
|
const transformBy = new MoveOperation(
|
|
|
@@ -2650,14 +2720,21 @@ describe( 'transform', () => {
|
|
|
|
|
|
const transOp = transform( op, transformBy );
|
|
|
|
|
|
- expect( transOp.length ).to.equal( 1 );
|
|
|
+ expect( transOp.length ).to.equal( 2 );
|
|
|
|
|
|
- expected.howMany = 2;
|
|
|
+ expected.howMany = 1;
|
|
|
+ expected.sourcePosition.path = [ 2, 2, 5 ];
|
|
|
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
+
|
|
|
+ expected.howMany = 1;
|
|
|
+ expected.sourcePosition.path = [ 2, 2, 4 ];
|
|
|
+ expected.baseVersion++;
|
|
|
+
|
|
|
+ expectOperation( transOp[ 1 ], expected );
|
|
|
} );
|
|
|
|
|
|
- it( 'range inside transforming range and is less important: split into two operations', () => {
|
|
|
+ it( 'range inside transforming range and is less important: split into three operations', () => {
|
|
|
op.howMany = 4;
|
|
|
|
|
|
const transformBy = new MoveOperation(
|
|
|
@@ -2667,20 +2744,26 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
- expect( transOp.length ).to.equal( 2 );
|
|
|
+ expect( transOp.length ).to.equal( 3 );
|
|
|
|
|
|
- expected.sourcePosition.path = [ 4, 1, 0 ];
|
|
|
- expected.howMany = 2;
|
|
|
+ expected.sourcePosition.path = [ 2, 2, 5 ];
|
|
|
+ expected.howMany = 1;
|
|
|
|
|
|
expectOperation( transOp[ 0 ], expected );
|
|
|
|
|
|
- expected.sourcePosition.path = [ 2, 2, 4 ];
|
|
|
+ expected.sourcePosition.path = [ 4, 1, 0 ];
|
|
|
expected.howMany = 2;
|
|
|
expected.baseVersion++;
|
|
|
|
|
|
expectOperation( transOp[ 1 ], expected );
|
|
|
+
|
|
|
+ expected.sourcePosition.path = [ 2, 2, 4 ];
|
|
|
+ expected.howMany = 1;
|
|
|
+ expected.baseVersion++;
|
|
|
+
|
|
|
+ expectOperation( transOp[ 2 ], expected );
|
|
|
} );
|
|
|
|
|
|
it( 'range and target inside transforming range and is important: no operation update', () => {
|
|
|
@@ -2712,7 +2795,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
@@ -2722,6 +2805,40 @@ describe( 'transform', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ describe( 'by RemoveOperation', () => {
|
|
|
+ let transformBy;
|
|
|
+
|
|
|
+ beforeEach( () => {
|
|
|
+ transformBy = new RemoveOperation(
|
|
|
+ Position.createFromPosition( op.sourcePosition ),
|
|
|
+ op.howMany,
|
|
|
+ new Position( doc.graveyard, [ 0 ] ),
|
|
|
+ baseVersion
|
|
|
+ );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should skip context.isStrong and be less important than RemoveOperation', () => {
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+
|
|
|
+ expectOperation( transOp[ 0 ], {
|
|
|
+ type: NoOperation,
|
|
|
+ baseVersion: baseVersion + 1
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should use context.isStrong if forceWeakRemove flag is used', () => {
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true, forceWeakRemove: true } );
|
|
|
+
|
|
|
+ expect( transOp.length ).to.equal( 1 );
|
|
|
+
|
|
|
+ expected.sourcePosition = transformBy.targetPosition;
|
|
|
+
|
|
|
+ expectOperation( transOp[ 0 ], expected );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'by NoOperation', () => {
|
|
|
it( 'no operation update', () => {
|
|
|
const transformBy = new NoOperation( baseVersion );
|
|
|
@@ -2758,48 +2875,9 @@ describe( 'transform', () => {
|
|
|
} );
|
|
|
|
|
|
describe( 'RemoveOperation', () => {
|
|
|
- describe( 'by InsertOperation', () => {
|
|
|
- it( 'should not need new graveyard holder if original operation did not needed it either', () => {
|
|
|
- const op = new RemoveOperation( new Position( root, [ 1 ] ), 1, baseVersion );
|
|
|
- op._needsHolderElement = false;
|
|
|
-
|
|
|
- const transformBy = new InsertOperation( new Position( root, [ 0 ] ), [ new Node() ], baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy )[ 0 ];
|
|
|
-
|
|
|
- expect( transOp._needsHolderElement ).to.be.false;
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
describe( 'by MoveOperation', () => {
|
|
|
- it( 'should create not more than one RemoveOperation that needs new graveyard holder', () => {
|
|
|
- const op = new RemoveOperation( new Position( root, [ 1 ] ), 4, baseVersion );
|
|
|
- const transformBy = new MoveOperation( new Position( root, [ 0 ] ), 2, new Position( root, [ 8 ] ), baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 2 );
|
|
|
-
|
|
|
- expect( transOp[ 0 ]._needsHolderElement ).to.be.true;
|
|
|
- expect( transOp[ 1 ]._needsHolderElement ).to.be.false;
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should not need new graveyard holder if original operation did not needed it either', () => {
|
|
|
- const op = new RemoveOperation( new Position( root, [ 1 ] ), 4, baseVersion );
|
|
|
- op._needsHolderElement = false;
|
|
|
-
|
|
|
- const transformBy = new MoveOperation( new Position( root, [ 0 ] ), 2, new Position( root, [ 8 ] ), baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 2 );
|
|
|
-
|
|
|
- expect( transOp[ 0 ]._needsHolderElement ).to.be.false;
|
|
|
- expect( transOp[ 1 ]._needsHolderElement ).to.be.false;
|
|
|
- } );
|
|
|
-
|
|
|
it( 'should force removing content even if was less important', () => {
|
|
|
- const op = new RemoveOperation( new Position( root, [ 8 ] ), 2, baseVersion );
|
|
|
+ const op = new RemoveOperation( new Position( root, [ 8 ] ), 2, new Position( doc.graveyard, [ 0 ] ), baseVersion );
|
|
|
|
|
|
const targetPosition = Position.createFromPosition( op.targetPosition );
|
|
|
|
|
|
@@ -2807,7 +2885,7 @@ describe( 'transform', () => {
|
|
|
|
|
|
const sourcePosition = Position.createFromPosition( transformBy.targetPosition );
|
|
|
|
|
|
- const transOp = transform( op, transformBy, false );
|
|
|
+ const transOp = transform( op, transformBy );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
@@ -2820,83 +2898,6 @@ describe( 'transform', () => {
|
|
|
} );
|
|
|
} );
|
|
|
} );
|
|
|
-
|
|
|
- describe( 'by RemoveOperation', () => {
|
|
|
- it( 'removes same nodes and transformed is weak: change howMany to 0', () => {
|
|
|
- const position = new Position( root, [ 2, 1 ] );
|
|
|
- const op = new RemoveOperation( position, 3, baseVersion );
|
|
|
- const transformBy = new RemoveOperation( position, 3, baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 1 );
|
|
|
- expectOperation( transOp[ 0 ], {
|
|
|
- type: RemoveOperation,
|
|
|
- howMany: 0,
|
|
|
- sourcePosition: new Position( doc.graveyard, [ 0, 0 ] ),
|
|
|
- targetPosition: new Position( doc.graveyard, [ 0, 0 ] ),
|
|
|
- baseVersion: baseVersion + 1
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'removes same nodes and transformed is strong: change source position', () => {
|
|
|
- const position = new Position( root, [ 2, 1 ] );
|
|
|
- const op = new RemoveOperation( position, 3, baseVersion );
|
|
|
- const transformBy = new RemoveOperation( position, 3, baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 1 );
|
|
|
- expectOperation( transOp[ 0 ], {
|
|
|
- type: RemoveOperation,
|
|
|
- howMany: 3,
|
|
|
- sourcePosition: new Position( doc.graveyard, [ 0, 0 ] ),
|
|
|
- targetPosition: new Position( doc.graveyard, [ 1, 0 ] ),
|
|
|
- baseVersion: baseVersion + 1
|
|
|
- } );
|
|
|
- } );
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
- describe( 'ReinsertOperation', () => {
|
|
|
- describe( 'by RemoveOperation', () => {
|
|
|
- it( 'should update sourcePosition if remove operation inserted holder offset before reinsert operation holder', () => {
|
|
|
- const position = new Position( root, [ 2, 1 ] );
|
|
|
- const transformBy = new RemoveOperation( position, 3, baseVersion );
|
|
|
- const op = new ReinsertOperation( new Position( doc.graveyard, [ 0, 0 ] ), 3, position, baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 1 );
|
|
|
-
|
|
|
- expectOperation( transOp[ 0 ], {
|
|
|
- type: ReinsertOperation,
|
|
|
- howMany: 3,
|
|
|
- sourcePosition: new Position( doc.graveyard, [ 1, 0 ] ),
|
|
|
- targetPosition: position,
|
|
|
- baseVersion: baseVersion + 1
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should not update sourcePosition if remove operation inserted holder offset after reinsert operation source', () => {
|
|
|
- const position = new Position( root, [ 2, 1 ] );
|
|
|
- const transformBy = new RemoveOperation( position, 3, baseVersion );
|
|
|
- transformBy.targetPosition = new Position( doc.graveyard, [ 3, 0 ] );
|
|
|
- const op = new ReinsertOperation( new Position( doc.graveyard, [ 2, 0 ] ), 3, position, baseVersion );
|
|
|
-
|
|
|
- const transOp = transform( op, transformBy );
|
|
|
-
|
|
|
- expect( transOp.length ).to.equal( 1 );
|
|
|
-
|
|
|
- expectOperation( transOp[ 0 ], {
|
|
|
- type: ReinsertOperation,
|
|
|
- howMany: 3,
|
|
|
- sourcePosition: new Position( doc.graveyard, [ 2, 0 ] ),
|
|
|
- targetPosition: position,
|
|
|
- baseVersion: baseVersion + 1
|
|
|
- } );
|
|
|
- } );
|
|
|
- } );
|
|
|
} );
|
|
|
|
|
|
describe( 'NoOperation', () => {
|
|
|
@@ -3158,7 +3159,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, false );
|
|
|
+ const transOp = transform( op, transformBy );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
expectOperation( transOp[ 0 ], {
|
|
|
@@ -3175,7 +3176,7 @@ describe( 'transform', () => {
|
|
|
baseVersion
|
|
|
);
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expect( transOp.length ).to.equal( 1 );
|
|
|
|
|
|
@@ -3470,7 +3471,7 @@ describe( 'transform', () => {
|
|
|
const anotherRange = Range.createFromParentsAndOffsets( root, 2, root, 2 );
|
|
|
const transformBy = new MarkerOperation( 'name', oldRange, anotherRange, doc.markers, baseVersion );
|
|
|
|
|
|
- const transOp = transform( op, transformBy, true );
|
|
|
+ const transOp = transform( op, transformBy, { isStrong: true } );
|
|
|
|
|
|
expected.oldRange = anotherRange;
|
|
|
|