Sfoglia il codice sorgente

Added tests for getAttrIterator().

Piotr Jasiun 10 anni fa
parent
commit
5afb45822d
1 ha cambiato i file con 23 aggiunte e 0 eliminazioni
  1. 23 0
      packages/ckeditor5-engine/tests/document/node.js

+ 23 - 0
packages/ckeditor5-engine/tests/document/node.js

@@ -5,8 +5,12 @@
 
 /* bender-tags: document */
 
+/* bender-include: ../_tools/tools.js */
+
 'use strict';
 
+const getIteratorCount = bender.tools.core.getIteratorCount;
+
 const modules = bender.amd.require(
 	'document/element',
 	'document/character',
@@ -206,6 +210,25 @@ describe( 'Node', () => {
 		} );
 	} );
 
+	describe( 'getAttrIterator', () => {
+		it( 'should allows to get attribute count', () => {
+			let element = new Element( 'foo', [
+				new Attribute( 1, true ),
+				new Attribute( 2, true ),
+				new Attribute( 3, true )
+			] );
+
+			expect( getIteratorCount( element.getAttrIterator() ) ).to.equal( 3 );
+		} );
+
+		it( 'should allows to copy attributes', () => {
+			let element = new Element( 'foo', [ new Attribute( 'x', true ) ] );
+			let copy = new Element( 'bar', element.getAttrIterator() );
+
+			expect( copy.getAttr( 'x' ) ).to.be.true;
+		} );
+	} );
+
 	describe( 'getIndex', () => {
 		it( 'should return null if the parent is null', () => {
 			expect( root.getIndex() ).to.be.null;