|
|
@@ -39,10 +39,10 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
it( 'should insert attribute to multiple ranges', function() {
|
|
|
@@ -68,10 +68,10 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 0 );
|
|
|
- expect( doc.root.children.get( 2 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChild( 2 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should add attribute to the existing attributes', function() {
|
|
|
@@ -97,11 +97,11 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should change attributes on multiple ranges', function() {
|
|
|
@@ -129,13 +129,13 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 2 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 2 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should change attribute to the set of nodes', function() {
|
|
|
@@ -160,13 +160,13 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 2 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should change attribute in the middle of existing attributes', function() {
|
|
|
@@ -193,11 +193,11 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( x2Attr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( x2Attr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should remove attribute', function() {
|
|
|
@@ -223,10 +223,10 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 2 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 2 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should remove attributes on multiple ranges', function() {
|
|
|
@@ -253,10 +253,10 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.version ) );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 0 );
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
it( 'should create a change operation as a reverse', function() {
|
|
|
@@ -310,10 +310,10 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.applyOperation( reverse );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 2 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 0 );
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 0 );
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 0 );
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
it( 'should undo change attribute by applying reverse operation', function() {
|
|
|
@@ -344,13 +344,13 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.applyOperation( reverse );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 2 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 2 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should undo remove attribute by applying reverse operation', function() {
|
|
|
@@ -380,13 +380,13 @@ describe( 'ChangeOperation', function() {
|
|
|
doc.applyOperation( reverse );
|
|
|
|
|
|
expect( doc.version ).to.be.equal( 2 );
|
|
|
- expect( doc.root.children.length ).to.be.equal( 3 );
|
|
|
- expect( doc.root.children.get( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 1 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
- expect( doc.root.children.get( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
- expect( doc.root.children.get( 2 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChildCount() ).to.be.equal( 3 );
|
|
|
+ expect( doc.root.getChild( 0 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 1 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 1 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
+ expect( doc.root.getChild( 2 ).attrs.length ).to.be.equal( 1 );
|
|
|
+ expect( doc.root.getChild( 2 ).hasAttr( fooAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should throw an error when one try to remove and the attribute does not exists', function() {
|