|
@@ -383,10 +383,18 @@ describe( 'Range', () => {
|
|
|
expect( transformed[ 1 ].end.path ).to.deep.equal( [ 5, 4 ] );
|
|
expect( transformed[ 1 ].end.path ).to.deep.equal( [ 5, 4 ] );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should expand range if insertion is equal to start boundary of the range', () => {
|
|
|
|
|
|
|
+ it( 'should not expand range if insertion is equal to start boundary of the range', () => {
|
|
|
const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 3, 8 ] ) );
|
|
const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 3, 8 ] ) );
|
|
|
const transformed = range.getTransformedByInsertion( new Position( root, [ 3, 2 ] ), 3 );
|
|
const transformed = range.getTransformedByInsertion( new Position( root, [ 3, 2 ] ), 3 );
|
|
|
|
|
|
|
|
|
|
+ expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 5 ] );
|
|
|
|
|
+ expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 11 ] );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should expand range if insertion is equal to start boundary of the range and sticky flag is set', () => {
|
|
|
|
|
+ const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 3, 8 ] ) );
|
|
|
|
|
+ const transformed = range.getTransformedByInsertion( new Position( root, [ 3, 2 ] ), 3, false, true );
|
|
|
|
|
+
|
|
|
expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
|
|
expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
|
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 11 ] );
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 11 ] );
|
|
|
} );
|
|
} );
|
|
@@ -399,10 +407,18 @@ describe( 'Range', () => {
|
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 11 ] );
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 3, 11 ] );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should expand range if insertion is equal to end boundary of the range', () => {
|
|
|
|
|
|
|
+ it( 'should not expand range if insertion is equal to end boundary of the range', () => {
|
|
|
const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 4, 4 ] ) );
|
|
const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 4, 4 ] ) );
|
|
|
const transformed = range.getTransformedByInsertion( new Position( root, [ 4, 4 ] ), 3 );
|
|
const transformed = range.getTransformedByInsertion( new Position( root, [ 4, 4 ] ), 3 );
|
|
|
|
|
|
|
|
|
|
+ expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
|
|
|
|
|
+ expect( transformed[ 0 ].end.path ).to.deep.equal( [ 4, 4 ] );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should expand range if insertion is equal to end boundary of the range and sticky flag is set', () => {
|
|
|
|
|
+ const range = new Range( new Position( root, [ 3, 2 ] ), new Position( root, [ 4, 4 ] ) );
|
|
|
|
|
+ const transformed = range.getTransformedByInsertion( new Position( root, [ 4, 4 ] ), 3, false, true );
|
|
|
|
|
+
|
|
|
expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
|
|
expect( transformed[ 0 ].start.path ).to.deep.equal( [ 3, 2 ] );
|
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 4, 7 ] );
|
|
expect( transformed[ 0 ].end.path ).to.deep.equal( [ 4, 7 ] );
|
|
|
} );
|
|
} );
|