Kaynağa Gözat

Tests: Converted to ES6.

Piotrek Koszuliński 10 yıl önce
ebeveyn
işleme
3f9db04af2
1 değiştirilmiş dosya ile 41 ekleme ve 41 silme
  1. 41 41
      packages/ckeditor5-engine/tests/editor/creator.js

+ 41 - 41
packages/ckeditor5-engine/tests/editor/creator.js

@@ -7,11 +7,11 @@
 
 /* bender-include: ../_tools/tools.js */
 
-var modules = bender.amd.require( 'editor', 'plugin', 'creator', 'ckeditorerror' );
-var editor, element;
+const modules = bender.amd.require( 'editor', 'plugin', 'creator', 'ckeditorerror' );
+let editor, element;
 
 function initEditor( config ) {
-	var Editor = modules.editor;
+	const Editor = modules.editor;
 
 	element = document.createElement( 'div' );
 	document.body.appendChild( element );
@@ -23,7 +23,7 @@ function initEditor( config ) {
 
 bender.tools.createSinonSandbox();
 
-before( function() {
+before( () => {
 	bender.tools.core.defineEditorCreatorMock( 'test1' );
 
 	bender.tools.core.defineEditorCreatorMock( 'test-any1' );
@@ -32,11 +32,11 @@ before( function() {
 	bender.tools.core.defineEditorCreatorMock( 'test-config1' );
 	bender.tools.core.defineEditorCreatorMock( 'test-config2' );
 
-	CKEDITOR.define( 'plugin!test3', [ 'plugin' ], function( Plugin ) {
+	CKEDITOR.define( 'plugin!test3', [ 'plugin' ], ( Plugin ) => {
 		return class extends Plugin {};
 	} );
 
-	CKEDITOR.define( 'plugin!creator-async-create', [ 'creator' ], function( Creator ) {
+	CKEDITOR.define( 'plugin!creator-async-create', [ 'creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {
 				return new Promise( ( resolve, reject ) => {
@@ -48,7 +48,7 @@ before( function() {
 		};
 	} );
 
-	CKEDITOR.define( 'plugin!creator-async-destroy', [ 'creator' ], function( Creator ) {
+	CKEDITOR.define( 'plugin!creator-async-destroy', [ 'creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {}
 
@@ -61,21 +61,21 @@ before( function() {
 	} );
 } );
 
-afterEach( function() {
+afterEach( () => {
 	editor = null; // To make sure we're using the freshly inited editor.
 } );
 
 ///////////////////
 
-describe( 'init', function() {
-	it( 'should instantiate the creator and call create()', function() {
-		var Creator = modules.creator;
+describe( 'init', () => {
+	it( 'should instantiate the creator and call create()', () => {
+		const Creator = modules.creator;
 
 		return initEditor( {
 				plugins: 'creator-test1'
 			} )
-			.then( function() {
-				var creator = editor.plugins.get( 'creator-test1' );
+			.then( () => {
+				let creator = editor.plugins.get( 'creator-test1' );
 
 				expect( creator ).to.be.instanceof( Creator );
 
@@ -84,69 +84,69 @@ describe( 'init', function() {
 			} );
 	} );
 
-	it( 'should instantiate any creator when more than one is available', function() {
+	it( 'should instantiate any creator when more than one is available', () => {
 		return initEditor( {
 				plugins: 'creator-test-any1,creator-test-any2'
 			} )
-			.then( function() {
-				var creator1 = editor.plugins.get( 'creator-test-any1' );
-				var creator2 = editor.plugins.get( 'creator-test-any2' );
+			.then( () => {
+				let creator1 = editor.plugins.get( 'creator-test-any1' );
+				let creator2 = editor.plugins.get( 'creator-test-any2' );
 
 				expect( creator1.create.called + creator2.create.called ).to.be.equal( 1, 'only one of the creators should be used' );
 			} );
 	} );
 
-	it( 'should use the creator specified in config.creator', function() {
+	it( 'should use the creator specified in config.creator', () => {
 		return initEditor( {
 				creator: 'test-config2',
 				plugins: 'creator-test-config1,creator-test-config2',
 			} )
-			.then( function() {
-				var creator1 = editor.plugins.get( 'creator-test-config1' );
-				var creator2 = editor.plugins.get( 'creator-test-config2' );
+			.then( () => {
+				let creator1 = editor.plugins.get( 'creator-test-config1' );
+				let creator2 = editor.plugins.get( 'creator-test-config2' );
 
 				sinon.assert.calledOnce( creator2.create );
 				sinon.assert.notCalled( creator1.create );
 			} );
 	} );
 
-	it( 'should throw an error if the creator doesn\'t exist', function() {
-		var CKEditorError = modules.ckeditorerror;
+	it( 'should throw an error if the creator doesn\'t exist', () => {
+		let CKEditorError = modules.ckeditorerror;
 
 		return initEditor( {
 				creator: 'bad',
 				plugins: 'creator-test1'
 			} )
-			.then( function() {
+			.then( () => {
 				throw new Error( 'This should not be executed.' );
 			} )
-			.catch( function( err ) {
+			.catch( ( err ) => {
 				expect( err ).to.be.instanceof( CKEditorError );
 				expect( err.message ).to.match( /^editor-creator-404:/ );
 			} );
 	} );
 
-	it( 'should throw an error no creators are defined', function() {
-		var CKEditorError = modules.ckeditorerror;
+	it( 'should throw an error no creators are defined', () => {
+		const CKEditorError = modules.ckeditorerror;
 
 		return initEditor( {} )
-			.then( function() {
+			.then( () => {
 				throw new Error( 'This should not be executed.' );
 			} )
-			.catch( function( err ) {
+			.catch( ( err ) => {
 				expect( err ).to.be.instanceof( CKEditorError );
 				expect( err.message ).to.match( /^editor-creator-404:/ );
 			} );
 	} );
 
-	it( 'should chain the promise from the creator (enables async creators)', function() {
+	it( 'should chain the promise from the creator (enables async creators)', () => {
 		return initEditor( {
 				plugins: 'creator-async-create'
 			} )
-			.then( function() {
+			.then( () => {
 				throw new Error( 'This should not be executed.' );
 			} )
-			.catch( function( err ) {
+			.catch( ( err ) => {
 				// Unfortunately fake timers don't work with promises, so throwing in the creator's create()
 				// seems to be the only way to test that the promise chain isn't broken.
 				expect( err ).to.have.property( 'message', 'Catch me - create.' );
@@ -154,34 +154,34 @@ describe( 'init', function() {
 	} );
 } );
 
-describe( 'destroy', function() {
-	it( 'should call "destroy" on the creator', function() {
-		var creator1;
+describe( 'destroy', () => {
+	it( 'should call "destroy" on the creator', () => {
+		let creator1;
 
 		return initEditor( {
 				plugins: 'creator-test1'
 			} )
-			.then( function() {
+			.then( () => {
 				creator1 = editor.plugins.get( 'creator-test1' );
 
 				return editor.destroy();
 			} )
-			.then( function() {
+			.then( () => {
 				sinon.assert.calledOnce( creator1.destroy );
 			} );
 	} );
 
-	it( 'should chain the promise from the creator (enables async creators)', function() {
+	it( 'should chain the promise from the creator (enables async creators)', () => {
 		return initEditor( {
 				plugins: 'creator-async-destroy'
 			} )
-			.then( function() {
+			.then( () => {
 				return editor.destroy();
 			} )
-			.then( function() {
+			.then( () => {
 				throw new Error( 'This should not be executed.' );
 			} )
-			.catch( function( err ) {
+			.catch( ( err ) => {
 				// Unfortunately fake timers don't work with promises, so throwing in the creator's destroy()
 				// seems to be the only way to test that the promise chain isn't broken.
 				expect( err ).to.have.property( 'message', 'Catch me - destroy.' );