|
|
@@ -51,9 +51,9 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 1 );
|
|
|
expect( root.getChildCount() ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( newAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 1 ).attrs.has( newAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 2 ).attrs.size ).to.equal( 0 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( newAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 1 ).hasAttribute( newAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 2 )._attrs.size ).to.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
it( 'should add attribute to the existing attributes', () => {
|
|
|
@@ -74,10 +74,10 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 1 );
|
|
|
expect( root.getChildCount() ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( newAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 0 ).attrs.has( barAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 3 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( newAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should change attribute to the set of nodes', () => {
|
|
|
@@ -97,12 +97,12 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 1 );
|
|
|
expect( root.getChildCount() ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( newAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 1 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 1 ).attrs.has( newAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 2 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 2 ).attrs.has( oldAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( newAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 1 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 1 ).hasAttribute( newAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 2 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 2 ).hasAttribute( oldAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should change attribute in the middle of existing attributes', () => {
|
|
|
@@ -124,10 +124,10 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 1 );
|
|
|
expect( root.getChildCount() ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 0 ).attrs.has( x2Attr ) ).to.be.true;
|
|
|
- expect( root.getChild( 0 ).attrs.has( barAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 3 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( x2Attr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should remove attribute', () => {
|
|
|
@@ -148,9 +148,9 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 1 );
|
|
|
expect( root.getChildCount() ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 2 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 0 ).attrs.has( barAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 2 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( barAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should create an AttributeOperation as a reverse', () => {
|
|
|
@@ -186,9 +186,9 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 2 );
|
|
|
expect( root.getChildCount() ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 0 );
|
|
|
- expect( root.getChild( 1 ).attrs.size ).to.equal( 0 );
|
|
|
- expect( root.getChild( 2 ).attrs.size ).to.equal( 0 );
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 0 );
|
|
|
+ expect( root.getChild( 1 )._attrs.size ).to.equal( 0 );
|
|
|
+ expect( root.getChild( 2 )._attrs.size ).to.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
it( 'should not set attribute of element if change range starts in the middle of that element', () => {
|
|
|
@@ -208,7 +208,7 @@ describe( 'AttributeOperation', () => {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.false;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
it( 'should not remove attribute of element if change range starts in the middle of that element', () => {
|
|
|
@@ -228,7 +228,7 @@ describe( 'AttributeOperation', () => {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should undo changing attribute by applying reverse operation', () => {
|
|
|
@@ -252,12 +252,12 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 2 );
|
|
|
expect( root.getChildCount() ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( oldAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 1 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 1 ).attrs.has( oldAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 2 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 2 ).attrs.has( oldAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( oldAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 1 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 1 ).hasAttribute( oldAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 2 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 2 ).hasAttribute( oldAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should undo remove attribute by applying reverse operation', () => {
|
|
|
@@ -280,12 +280,12 @@ describe( 'AttributeOperation', () => {
|
|
|
|
|
|
expect( doc.version ).to.equal( 2 );
|
|
|
expect( root.getChildCount() ).to.equal( 3 );
|
|
|
- expect( root.getChild( 0 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 0 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 1 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 1 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
- expect( root.getChild( 2 ).attrs.size ).to.equal( 1 );
|
|
|
- expect( root.getChild( 2 ).attrs.has( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 0 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 0 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 1 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 1 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
+ expect( root.getChild( 2 )._attrs.size ).to.equal( 1 );
|
|
|
+ expect( root.getChild( 2 ).hasAttribute( fooAttr ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should throw an error when one try to remove and the attribute does not exists', () => {
|