panr 5 anni fa
parent
commit
fe30d83816
1 ha cambiato i file con 11 aggiunte e 15 eliminazioni
  1. 11 15
      packages/ckeditor5-typing/tests/texttransformation.js

+ 11 - 15
packages/ckeditor5-typing/tests/texttransformation.js

@@ -42,35 +42,31 @@ describe( 'Text transformation feature', () => {
 	} );
 
 	describe( 'plugin', () => {
-		let TextTransformationPlugin, enableWatchersSpy, disableWatchersSpy;
+		let TextTransformationPlugin;
 
 		beforeEach( () => {
-			TextTransformationPlugin = new TextTransformation( editor );
-			enableWatchersSpy = sinon.spy( TextTransformationPlugin, '_enableTransformationWatchers' );
-			disableWatchersSpy = sinon.spy( TextTransformationPlugin, '_disableTransformationWatchers' );
-
-			TextTransformationPlugin.init();
+			return createEditorInstance().then( () => {
+				TextTransformationPlugin = editor.plugins.get( 'TextTransformation' );
+			} );
 		} );
 
 		it( 'should be enabled after initialization', () => {
+			TextTransformationPlugin.init();
+
 			expect( TextTransformationPlugin.isEnabled ).to.be.true;
 		} );
 
 		it( 'should initialize watchers after initialization', () => {
-			sinon.assert.calledOnce( enableWatchersSpy );
-		} );
+			const enableWatchersSpy = sinon.spy( TextTransformationPlugin, '_enableTransformationWatchers' );
 
-		it( 'should initialize watchers again when is enabled', () => {
-			sinon.assert.calledOnce( enableWatchersSpy );
-
-			TextTransformationPlugin.isEnabled = false;
-			TextTransformationPlugin.isEnabled = true;
+			TextTransformationPlugin.init();
 
-			sinon.assert.calledTwice( enableWatchersSpy );
-			expect( TextTransformationPlugin._watchersStack.size ).to.be.at.least( 1 );
+			sinon.assert.calledOnce( enableWatchersSpy );
 		} );
 
 		it( 'should disable watchers when is disabled', () => {
+			const disableWatchersSpy = sinon.spy( TextTransformationPlugin, '_disableTransformationWatchers' );
+
 			TextTransformationPlugin.isEnabled = false;
 
 			sinon.assert.calledOnce( disableWatchersSpy );