瀏覽代碼

Upgraded tests to the latest Chai and Sinon version.

Kamil Piechaczek 8 年之前
父節點
當前提交
51d37ed37a

+ 5 - 10
packages/ckeditor5-utils/tests/collection.js

@@ -444,9 +444,7 @@ describe( 'Collection', () => {
 
 	describe( 'map()', () => {
 		it( 'uses native map', () => {
-			const spy = testUtils.sinon.stub( Array.prototype, 'map', () => {
-				return [ 'foo' ];
-			} );
+			const spy = testUtils.sinon.stub( Array.prototype, 'map' ).returns( [ 'foo' ] );
 			const ctx = {};
 
 			const ret = collection.map( callback, ctx );
@@ -462,9 +460,7 @@ describe( 'Collection', () => {
 		it( 'uses native find', () => {
 			const needl = getItem( 'foo' );
 
-			const spy = testUtils.sinon.stub( Array.prototype, 'find', () => {
-				return needl;
-			} );
+			const spy = testUtils.sinon.stub( Array.prototype, 'find' ).returns( needl );
 			const ctx = {};
 
 			const ret = collection.find( callback, ctx );
@@ -480,9 +476,8 @@ describe( 'Collection', () => {
 		it( 'uses native filter', () => {
 			const needl = getItem( 'foo' );
 
-			const spy = testUtils.sinon.stub( Array.prototype, 'filter', () => {
-				return [ needl ];
-			} );
+			// See: https://github.com/sinonjs/sinon/issues/1521
+			const spy = testUtils.sinon.stub( collection._items, 'filter' ).returns( [ needl ] );
 			const ctx = {};
 
 			const ret = collection.filter( callback, ctx );
@@ -891,7 +886,7 @@ describe( 'Collection', () => {
 				assertItems( collectionA, [ 4, 6, 8 ] );
 				assertItems( collectionB, [ 4, 6, 8 ] );
 
-				expect( collectionA ).to.deep.equal( collectionB );
+				expect( [ ...collectionA ] ).to.deep.equal( [ ...collectionB ] );
 
 				sinon.assert.callCount( spyA, 3 );
 				sinon.assert.callCount( spyB, 3 );

+ 2 - 2
packages/ckeditor5-utils/tests/dom/global.js

@@ -18,7 +18,7 @@ describe( 'global', () => {
 			} );
 
 			it( 'stubs', () => {
-				testUtils.sinon.stub( global, 'window', {
+				testUtils.sinon.stub( global, 'window' ).value( {
 					scrollX: 100
 				} );
 
@@ -34,7 +34,7 @@ describe( 'global', () => {
 			} );
 
 			it( 'stubs', () => {
-				testUtils.sinon.stub( global, 'document', {
+				testUtils.sinon.stub( global, 'document' ).value( {
 					foo: 'abc'
 				} );
 

+ 1 - 1
packages/ckeditor5-utils/tests/dom/rect.js

@@ -749,7 +749,7 @@ describe( 'Rect', () => {
 		} );
 
 		it( 'should return the viewport\'s rect', () => {
-			testUtils.sinon.stub( global, 'window', {
+			testUtils.sinon.stub( global, 'window' ).value( {
 				innerWidth: 1000,
 				innerHeight: 500,
 				scrollX: 100,