Parcourir la source

Upgraded tests to the latest Chai and Sinon version.

Kamil Piechaczek il y a 8 ans
Parent
commit
ee19a5175d

+ 1 - 1
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -186,7 +186,7 @@ describe( 'BalloonPanelView', () => {
 				}
 			};
 
-			testUtils.sinon.stub( global, 'window', windowStub );
+			testUtils.sinon.stub( global, 'window' ).value( windowStub );
 		} );
 
 		it( 'should use default options', () => {

+ 2 - 2
packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js

@@ -28,8 +28,8 @@ describe( 'ContextualBalloon', () => {
 
 			// We don't need to execute BalloonPanel pin and attachTo methods
 			// it's enough to check if was called with the proper data.
-			sinon.stub( balloon.view, 'attachTo', () => {} );
-			sinon.stub( balloon.view, 'pin', () => {} );
+			sinon.stub( balloon.view, 'attachTo' ).returns( {} );
+			sinon.stub( balloon.view, 'pin' ).returns( {} );
 
 			viewA = new View();
 			viewB = new View();

+ 6 - 8
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -37,8 +37,8 @@ describe( 'ContextualToolbar', () => {
 			balloon = editor.plugins.get( ContextualBalloon );
 
 			// There is no point to execute BalloonPanelView attachTo and pin methods so lets override it.
-			sandbox.stub( balloon.view, 'attachTo', () => {} );
-			sandbox.stub( balloon.view, 'pin', () => {} );
+			sandbox.stub( balloon.view, 'attachTo' ).returns( {} );
+			sandbox.stub( balloon.view, 'pin' ).returns( {} );
 
 			// Focus the engine.
 			editor.editing.view.isFocused = true;
@@ -276,7 +276,7 @@ describe( 'ContextualToolbar', () => {
 		let removeBalloonSpy;
 
 		beforeEach( () => {
-			removeBalloonSpy = sandbox.stub( balloon, 'remove', () => {} );
+			removeBalloonSpy = sandbox.stub( balloon, 'remove' ).returns( {} );
 			editor.editing.view.isFocused = true;
 		} );
 
@@ -397,8 +397,7 @@ describe( 'ContextualToolbar', () => {
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
-			// Stubbing getters doesn't wor for sandbox.
-			const stub = sinon.stub( balloon, 'visibleView', { get: () => contextualToolbar.toolbarView } );
+			const stub = sinon.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -416,8 +415,7 @@ describe( 'ContextualToolbar', () => {
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
-			// Stubbing getters doesn't wor for sandbox.
-			const stub = sinon.stub( balloon, 'visibleView', { get: () => null } );
+			const stub = sinon.stub( balloon, 'visibleView' ).get( () => null );
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -459,7 +457,7 @@ describe( 'ContextualToolbar', () => {
 		const originalViewRangeToDom = editingView.domConverter.viewRangeToDom;
 
 		// Mock selection rect.
-		sandbox.stub( editingView.domConverter, 'viewRangeToDom', ( ...args ) => {
+		sandbox.stub( editingView.domConverter, 'viewRangeToDom' ).callsFake( ( ...args ) => {
 			const domRange = originalViewRangeToDom.apply( editingView.domConverter, args );
 
 			sandbox.stub( domRange, 'getClientRects' )

+ 1 - 1
packages/ckeditor5-ui/tests/toolbar/sticky/stickytoolbarview.js

@@ -34,7 +34,7 @@ describe( 'StickyToolbarView', () => {
 			scrollY: 0
 		} );
 
-		testUtils.sinon.stub( global, 'window', windowStub );
+		testUtils.sinon.stub( global, 'window' ).value( windowStub );
 
 		document.body.appendChild( element );
 	} );