|
|
@@ -114,8 +114,8 @@ describe( 'MoveOperation', () => {
|
|
|
expect( reverse ).to.be.an.instanceof( MoveOperation );
|
|
|
expect( reverse.baseVersion ).to.equal( 1 );
|
|
|
expect( reverse.howMany ).to.equal( nodeList.length );
|
|
|
- expect( reverse.sourcePosition ).to.equal( targetPosition );
|
|
|
- expect( reverse.targetPosition ).to.equal( sourcePosition );
|
|
|
+ expect( reverse.sourcePosition.isEqual( targetPosition ) ).to.be.true;
|
|
|
+ expect( reverse.targetPosition.isEqual( sourcePosition ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should undo move node by applying reverse operation', () => {
|
|
|
@@ -151,18 +151,14 @@ describe( 'MoveOperation', () => {
|
|
|
it( 'should throw an error if number of nodes to move exceeds the number of existing nodes in given element', () => {
|
|
|
root.insertChildren( 0, 'xbarx' );
|
|
|
|
|
|
- expect(
|
|
|
- () => {
|
|
|
- doc.applyOperation(
|
|
|
- new MoveOperation(
|
|
|
- new Position( [ 3 ], root ),
|
|
|
- new Position( [ 1 ], root ),
|
|
|
- 3,
|
|
|
- doc.version
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
- ).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
|
|
|
+ let operation = new MoveOperation(
|
|
|
+ new Position( [ 3 ], root ),
|
|
|
+ new Position( [ 1 ], root ),
|
|
|
+ 3,
|
|
|
+ doc.version
|
|
|
+ );
|
|
|
+
|
|
|
+ expect( () => doc.applyOperation( operation ) ).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw an error if target or source parent-element specified by position does not exist', () => {
|
|
|
@@ -179,11 +175,7 @@ describe( 'MoveOperation', () => {
|
|
|
|
|
|
root.removeChildren( 2, 1 );
|
|
|
|
|
|
- expect(
|
|
|
- () => {
|
|
|
- doc.applyOperation( operation );
|
|
|
- }
|
|
|
- ).to.throw( CKEditorError, /operation-move-position-invalid/ );
|
|
|
+ expect( () => doc.applyOperation( operation ) ).to.throw( CKEditorError, /operation-move-position-invalid/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw an error if operation tries to move a range between the beginning and the end of that range', () => {
|
|
|
@@ -196,11 +188,7 @@ describe( 'MoveOperation', () => {
|
|
|
doc.version
|
|
|
);
|
|
|
|
|
|
- expect(
|
|
|
- () => {
|
|
|
- doc.applyOperation( operation );
|
|
|
- }
|
|
|
- ).to.throw( CKEditorError, /operation-move-range-into-itself/ );
|
|
|
+ expect( () => doc.applyOperation( operation ) ).to.throw( CKEditorError, /operation-move-range-into-itself/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw an error if operation tries to move a range into a sub-tree of a node that is in that range', () => {
|
|
|
@@ -214,11 +202,7 @@ describe( 'MoveOperation', () => {
|
|
|
doc.version
|
|
|
);
|
|
|
|
|
|
- expect(
|
|
|
- () => {
|
|
|
- doc.applyOperation( operation );
|
|
|
- }
|
|
|
- ).to.throw( CKEditorError, /operation-move-node-into-itself/ );
|
|
|
+ expect( () => doc.applyOperation( operation ) ).to.throw( CKEditorError, /operation-move-node-into-itself/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should not throw an error if operation move a range into a sibling', () => {
|