|
@@ -1425,29 +1425,50 @@ describe( 'Writer', () => {
|
|
|
expect( docFrag.getChild( 0 ).getChild( 0 ).data ).to.equal( 'foobar' );
|
|
expect( docFrag.getChild( 0 ).getChild( 0 ).data ).to.equal( 'foobar' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should create a marker operation if a marker was affected', () => {
|
|
|
|
|
- const markerRange = new Range( Position._createAt( p2, 0 ), Position._createAt( p2, 0 ) );
|
|
|
|
|
|
|
+ describe( 'should create a marker operation if a marker was affected', () => {
|
|
|
|
|
+ it( '<p>Foo[</p><p>Bar]</p>', () => {
|
|
|
|
|
+ test( p1, 'end', p2, 0 );
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- addMarker( 'name', {
|
|
|
|
|
- range: markerRange,
|
|
|
|
|
- usingOperation: true
|
|
|
|
|
|
|
+ it( '<p>[Foo</p><p>]Bar</p>', () => {
|
|
|
|
|
+ test( p1, 0, p2, 0 );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- const documentVersion = model.document.version;
|
|
|
|
|
|
|
+ it( '<p>[Foo</p>]<p>Bar</p>', () => {
|
|
|
|
|
+ test( p1, 0, root, 1 );
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- merge( Position._createAfter( p1 ) );
|
|
|
|
|
|
|
+ it( '<p>Foo</p>[<p>Bar]</p>', () => {
|
|
|
|
|
+ test( root, 1, p2, 'end' );
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- const history = model.document.history;
|
|
|
|
|
|
|
+ function test( startElement, startOffset, endElement, endOffset ) {
|
|
|
|
|
+ const markerRange = new Range(
|
|
|
|
|
+ Position._createAt( startElement, startOffset ),
|
|
|
|
|
+ Position._createAt( endElement, endOffset )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- const lastOperation = history._operations[ history._operations.length - 1 ];
|
|
|
|
|
- const secondLastOperation = history._operations[ history._operations.length - 2 ];
|
|
|
|
|
|
|
+ addMarker( 'name', {
|
|
|
|
|
+ range: markerRange,
|
|
|
|
|
+ usingOperation: true
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- expect( secondLastOperation.type ).to.equal( 'marker' );
|
|
|
|
|
- expect( secondLastOperation.oldRange.isEqual( markerRange ) );
|
|
|
|
|
- expect( secondLastOperation.newRange.isEqual( markerRange ) );
|
|
|
|
|
|
|
+ const documentVersion = model.document.version;
|
|
|
|
|
|
|
|
- expect( lastOperation.type ).to.equal( 'merge' );
|
|
|
|
|
- expect( model.document.version ).to.equal( documentVersion + 2 );
|
|
|
|
|
|
|
+ merge( Position._createAfter( p1 ) );
|
|
|
|
|
+
|
|
|
|
|
+ const history = model.document.history;
|
|
|
|
|
+
|
|
|
|
|
+ const lastOperation = history._operations[ history._operations.length - 1 ];
|
|
|
|
|
+ const secondLastOperation = history._operations[ history._operations.length - 2 ];
|
|
|
|
|
+
|
|
|
|
|
+ expect( secondLastOperation.type ).to.equal( 'marker' );
|
|
|
|
|
+ expect( secondLastOperation.oldRange.isEqual( markerRange ) );
|
|
|
|
|
+ expect( secondLastOperation.newRange.isEqual( markerRange ) );
|
|
|
|
|
+
|
|
|
|
|
+ expect( lastOperation.type ).to.equal( 'merge' );
|
|
|
|
|
+ expect( model.document.version ).to.equal( documentVersion + 2 );
|
|
|
|
|
+ }
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not create a marker operation if affected marker was not using operations', () => {
|
|
it( 'should not create a marker operation if affected marker was not using operations', () => {
|