Parcourir la source

Use sinon-chai and named spies in twostepcaretmovement.js.

Tomek Wytrębowicz il y a 5 ans
Parent
commit
2d964fab89
1 fichiers modifiés avec 17 ajouts et 18 suppressions
  1. 17 18
      packages/ckeditor5-typing/tests/twostepcaretmovement.js

+ 17 - 18
packages/ckeditor5-typing/tests/twostepcaretmovement.js

@@ -31,8 +31,8 @@ describe( 'TwoStepCaretMovement()', () => {
 			view = editor.editing.view;
 			plugin = editor.plugins.get( TwoStepCaretMovement );
 
-			preventDefaultSpy = sinon.spy();
-			evtStopSpy = sinon.spy();
+			preventDefaultSpy = sinon.spy().named( 'preventDefaultSpy' );
+			evtStopSpy = sinon.spy().named( 'evtStopSpy' );
 
 			editor.model.schema.extend( '$text', {
 				allowAttributes: [ 'a', 'b', 'c' ],
@@ -657,9 +657,9 @@ describe( 'TwoStepCaretMovement()', () => {
 	} );
 
 	it( 'should listen with the high+1 priority on view.document#keydown', () => {
-		const highestPrioritySpy = sinon.spy();
-		const highPrioritySpy = sinon.spy();
-		const normalPrioritySpy = sinon.spy();
+		const highestPrioritySpy = sinon.spy().named( 'highestPrioritySpy' );
+		const highPrioritySpy = sinon.spy().named( 'highPrioritySpy' );
+		const normalPrioritySpy = sinon.spy().named( 'normalPrioritySpy' );
 
 		setData( model, '<$text c="true">foo[]</$text><$text a="true" b="true">bar</$text>' );
 
@@ -672,12 +672,11 @@ describe( 'TwoStepCaretMovement()', () => {
 			preventDefault: preventDefaultSpy
 		} );
 
-		sinon.assert.callOrder(
-			highestPrioritySpy,
-			preventDefaultSpy );
+		expect( highestPrioritySpy ).to.be.calledOnce;
+		expect( preventDefaultSpy ).to.be.calledImmediatelyAfter( highestPrioritySpy );
 
-		sinon.assert.notCalled( highPrioritySpy );
-		sinon.assert.notCalled( normalPrioritySpy );
+		expect( highPrioritySpy ).not.to.be.called;
+		expect( normalPrioritySpy ).not.to.be.called;
 	} );
 
 	it( 'should do nothing when key other then arrow left and right is pressed', () => {
@@ -758,8 +757,8 @@ describe( 'TwoStepCaretMovement()', () => {
 				keyCode: keyCodes.arrowright
 			} );
 
-			sinon.assert.calledOnce( forwardStub );
-			sinon.assert.notCalled( backwardStub );
+			expect( forwardStub ).to.be.calledOnce;
+			expect( backwardStub ).not.to.be.called;
 
 			setData( model, '<$text>foo</$text><$text a="true">[]bar</$text>' );
 
@@ -767,8 +766,8 @@ describe( 'TwoStepCaretMovement()', () => {
 				keyCode: keyCodes.arrowleft
 			} );
 
-			sinon.assert.calledOnce( backwardStub );
-			sinon.assert.calledOnce( forwardStub );
+			expect( forwardStub ).to.be.calledOnce;
+			expect( backwardStub ).to.be.calledOnce;
 		} );
 
 		it( 'should use the opposite helper methods (RTL content direction)', () => {
@@ -811,8 +810,8 @@ describe( 'TwoStepCaretMovement()', () => {
 						keyCode: keyCodes.arrowleft
 					} );
 
-					sinon.assert.calledOnce( forwardStub );
-					sinon.assert.notCalled( backwardStub );
+					expect( forwardStub ).to.be.calledOnce;
+					expect( backwardStub ).not.to.be.called;
 
 					setData( model, '<$text>foo</$text><$text a="true">[]bar</$text>' );
 
@@ -820,8 +819,8 @@ describe( 'TwoStepCaretMovement()', () => {
 						keyCode: keyCodes.arrowright
 					} );
 
-					sinon.assert.calledOnce( backwardStub );
-					sinon.assert.calledOnce( forwardStub );
+					expect( forwardStub ).to.be.calledOnce;
+					expect( backwardStub ).to.be.calledOnce;
 
 					return newEditor.destroy();
 				} );