浏览代码

Added test for the iterator's item consumption.

Maciej Bukowski 8 年之前
父节点
当前提交
deac828873
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      packages/ckeditor5-utils/tests/first.js

+ 13 - 2
packages/ckeditor5-utils/tests/first.js

@@ -8,15 +8,26 @@ import first from '../src/first';
 describe( 'utils', () => {
 	describe( 'first', () => {
 		it( 'should return first item', () => {
-			const iterator = [ 11, 22 ][ Symbol.iterator ]();
+			const collection = [ 11, 22 ];
+			const iterator = collection[ Symbol.iterator ]();
 
 			expect( first( iterator ) ).to.equal( 11 );
 		} );
 
 		it( 'should return null if iterator is empty', () => {
-			const iterator = [][ Symbol.iterator ]();
+			const collection = [];
+			const iterator = collection[ Symbol.iterator ]();
 
 			expect( first( iterator ) ).to.be.null;
 		} );
+
+		it( 'should consume the iterating item', () => {
+			const collection = [ 11, 22 ];
+			const iterator = collection[ Symbol.iterator ]();
+
+			first( iterator );
+
+			expect( iterator.next().value ).to.equal( 22 );
+		} );
 	} );
 } );