Procházet zdrojové kódy

Updated defineEditorCreatorMock, because create() and destroy() are now always defined.

Piotrek Koszuliński před 9 roky
rodič
revize
2a3ba7416b

+ 0 - 13
packages/ckeditor5-engine/tests/_utils/utils.js

@@ -14,11 +14,6 @@ const utils = {
 	/**
 	 * Defines CKEditor plugin which is a mock of an editor creator.
 	 *
-	 * If `proto` is not set or it does not define `create()` and `destroy()` methods,
-	 * then they will be set to Sinon spies. Therefore the shortest usage is:
-	 *
-	 *		testUtils.defineEditorCreatorMock( 'test1' );
-	 *
 	 * The mocked creator is available under:
 	 *
 	 *		editor.plugins.get( 'creator-thename' );
@@ -37,14 +32,6 @@ const utils = {
 				}
 			}
 
-			if ( !TestCreator.prototype.create ) {
-				TestCreator.prototype.create = sinon.spy().named( creatorName + '-create' );
-			}
-
-			if ( !TestCreator.prototype.destroy ) {
-				TestCreator.prototype.destroy = sinon.spy().named( creatorName + '-destroy' );
-			}
-
 			return TestCreator;
 		} );
 	},

+ 10 - 3
packages/ckeditor5-engine/tests/editor/creator.js

@@ -28,13 +28,20 @@ function initEditor( config ) {
 testUtils.createSinonSandbox();
 
 before( () => {
-	coreTestUtils.defineEditorCreatorMock( 'test1' );
+	coreTestUtils.defineEditorCreatorMock( 'test1', {
+		create: sinon.spy(),
+		destroy: sinon.spy()
+	} );
 
 	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many1' );
 	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many2' );
 
-	coreTestUtils.defineEditorCreatorMock( 'test-config1' );
-	coreTestUtils.defineEditorCreatorMock( 'test-config2' );
+	coreTestUtils.defineEditorCreatorMock( 'test-config1', {
+		create: sinon.spy()
+	} );
+	coreTestUtils.defineEditorCreatorMock( 'test-config2', {
+		create: sinon.spy()
+	} );
 
 	amdUtils.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
 		return class extends Plugin {};

+ 0 - 8
packages/ckeditor5-engine/tests/utils-tests/utils.js

@@ -53,15 +53,7 @@ describe( 'coreTestUtils.defineEditorCreatorMock()', () => {
 	it( 'should copy properties from the second argument', () => {
 		expect( TestCreator2.prototype ).to.have.property( 'foo', 1 );
 		expect( TestCreator2.prototype ).to.have.property( 'bar', 2 );
-	} );
-
-	it( 'should create spies for create() and destroy() if not defined', () => {
-		expect( TestCreator1.prototype.create ).to.have.property( 'called', false, 'test1.create' );
-		expect( TestCreator1.prototype.destroy ).to.have.property( 'called', false, 'test1.destroy' );
-		expect( TestCreator2.prototype.create ).to.have.property( 'called', false, 'test2.create' );
-		expect( TestCreator2.prototype.destroy ).to.have.property( 'called', false, 'test2.destroy' );
 
-		// Not spies:
 		expect( TestCreator3.prototype ).to.have.property( 'create', createFn3 );
 		expect( TestCreator3.prototype ).to.have.property( 'destroy', destroyFn3 );
 	} );