Преглед изворни кода

Tests: Use const for classes.

Piotrek Koszuliński пре 10 година
родитељ
комит
8e55898d6a

+ 1 - 1
packages/ckeditor5-ui/src/emittermixin.js

@@ -13,7 +13,7 @@
  */
 
 CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
-	var EmitterMixin = {
+	const EmitterMixin = {
 		/**
 		 * Registers a callback function to be executed when an event is fired.
 		 *

+ 1 - 1
packages/ckeditor5-ui/src/ui/domemittermixin.js

@@ -37,7 +37,7 @@
  */
 
 CKEDITOR.define( [ 'emittermixin', 'utils', 'log' ], function( EmitterMixin, utils, log ) {
-	var DOMEmitterMixin = {
+	const DOMEmitterMixin = {
 		/**
 		 * Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node.
 		 * It is backwards compatible with {@link EmitterMixin#listenTo}.

+ 8 - 8
packages/ckeditor5-ui/tests/bender/tools.js

@@ -26,10 +26,10 @@ const modules = bender.amd.require( 'creator', 'plugin!creator-test1', 'plugin!c
 
 describe( 'bender.tools.core.defineEditorCreatorMock()', function() {
 	it( 'should register all creators', function() {
-		var Creator = modules.creator;
-		var TestCreator1 = modules[ 'plugin!creator-test1' ];
-		var TestCreator2 = modules[ 'plugin!creator-test2' ];
-		var TestCreator3 = modules[ 'plugin!creator-test3' ];
+		const Creator = modules.creator;
+		const TestCreator1 = modules[ 'plugin!creator-test1' ];
+		const TestCreator2 = modules[ 'plugin!creator-test2' ];
+		const TestCreator3 = modules[ 'plugin!creator-test3' ];
 
 		expect( TestCreator1.prototype ).to.be.instanceof( Creator );
 		expect( TestCreator2.prototype ).to.be.instanceof( Creator );
@@ -37,16 +37,16 @@ describe( 'bender.tools.core.defineEditorCreatorMock()', function() {
 	} );
 
 	it( 'should copy properties from the second argument', function() {
-		var TestCreator = modules[ 'plugin!creator-test2' ];
+		const TestCreator = modules[ 'plugin!creator-test2' ];
 
 		expect( TestCreator.prototype ).to.have.property( 'foo', 1 );
 		expect( TestCreator.prototype ).to.have.property( 'bar', 2 );
 	} );
 
 	it( 'should create spies for create() and destroy() if not defined', function() {
-		var TestCreator1 = modules[ 'plugin!creator-test1' ];
-		var TestCreator2 = modules[ 'plugin!creator-test2' ];
-		var TestCreator3 = modules[ 'plugin!creator-test3' ];
+		const TestCreator1 = modules[ 'plugin!creator-test1' ];
+		const TestCreator2 = modules[ 'plugin!creator-test2' ];
+		const TestCreator3 = modules[ 'plugin!creator-test3' ];
 
 		expect( TestCreator1.prototype.create ).to.have.property( 'called', false, 'test1.create' );
 		expect( TestCreator1.prototype.destroy ).to.have.property( 'called', false, 'test1.destroy' );

+ 1 - 1
packages/ckeditor5-ui/tests/collection/collection.js

@@ -16,7 +16,7 @@ function getItem( id, idProperty ) {
 }
 
 describe( 'Collection', () => {
-	var Collection, CKEditorError;
+	let Collection, CKEditorError;
 
 	before( () => {
 		Collection = modules.collection;

+ 6 - 6
packages/ckeditor5-ui/tests/config/config.js

@@ -10,7 +10,7 @@ const modules = bender.amd.require( 'config' );
 var config;
 
 beforeEach( function() {
-	var Config = modules.config;
+	const Config = modules.config;
 
 	config = new Config( {
 		creator: 'inline',
@@ -38,7 +38,7 @@ describe( 'constructor', function() {
 	} );
 
 	it( 'should work with no parameters', function() {
-		var Config = modules.config;
+		const Config = modules.config;
 
 		// No error should be thrown.
 		config = new Config();
@@ -47,7 +47,7 @@ describe( 'constructor', function() {
 
 describe( 'set', function() {
 	it( 'should create Config instances for objects', function() {
-		var Config = modules.config;
+		const Config = modules.config;
 
 		expect( config.resize ).to.be.an.instanceof( Config );
 		expect( config.resize.icon ).to.be.an.instanceof( Config );
@@ -112,7 +112,7 @@ describe( 'set', function() {
 	} );
 
 	it( 'should replace a simple entry with a Config instance', function() {
-		var Config = modules.config;
+		const Config = modules.config;
 
 		config.set( 'test', 1 );
 		config.set( 'test', {
@@ -124,7 +124,7 @@ describe( 'set', function() {
 	} );
 
 	it( 'should replace a simple entry with a Config instance when passing an object', function() {
-		var Config = modules.config;
+		const Config = modules.config;
 
 		config.set( 'test', 1 );
 		config.set( {
@@ -138,7 +138,7 @@ describe( 'set', function() {
 	} );
 
 	it( 'should replace a simple entry with a Config instance when passing a name.with.deep', function() {
-		var Config = modules.config;
+		const Config = modules.config;
 
 		config.set( 'test.prop', 1 );
 		config.set( 'test.prop.value', 1 );

+ 2 - 2
packages/ckeditor5-ui/tests/editorconfig/editorconfig.js

@@ -10,7 +10,7 @@ const modules = bender.amd.require( 'editorconfig', 'ckeditor' );
 var config;
 
 beforeEach( function() {
-	var EditorConfig = modules.editorconfig;
+	const EditorConfig = modules.editorconfig;
 
 	config = new EditorConfig( {
 		test: 1
@@ -29,7 +29,7 @@ describe( 'get', function() {
 	} );
 
 	it( 'should fallback to CKEDITOR.config', function() {
-		var CKEDITOR = modules.ckeditor;
+		const CKEDITOR = modules.ckeditor;
 
 		CKEDITOR.config.set( {
 			globalConfig: 2

+ 3 - 3
packages/ckeditor5-ui/tests/emittermixin/emittermixin.js

@@ -45,7 +45,7 @@ describe( 'fire', function() {
 	} );
 
 	it( 'should pass arguments to callbacks', function() {
-		var EventInfo = modules.eventinfo;
+		const EventInfo = modules.eventinfo;
 
 		var spy1 = sinon.spy();
 		var spy2 = sinon.spy();
@@ -212,7 +212,7 @@ describe( 'once', function() {
 	} );
 
 	it( 'should have proper arguments', function() {
-		var EventInfo = modules.eventinfo;
+		const EventInfo = modules.eventinfo;
 
 		var spy = sinon.spy();
 
@@ -419,7 +419,7 @@ function refreshListener() {
 }
 
 function getEmitterInstance() {
-	var EmitterMixin = modules.emittermixin;
+	const EmitterMixin = modules.emittermixin;
 	var utils = modules.utils;
 
 	return utils.extend( {}, EmitterMixin );

+ 3 - 3
packages/ckeditor5-ui/tests/eventinfo/eventinfo.js

@@ -9,7 +9,7 @@ const modules = bender.amd.require( 'eventinfo' );
 
 describe( 'EventInfo', function() {
 	it( 'should be created properly', function() {
-		var EventInfo = modules.eventinfo;
+		const EventInfo = modules.eventinfo;
 
 		var event = new EventInfo( this, 'test' );
 
@@ -20,7 +20,7 @@ describe( 'EventInfo', function() {
 	} );
 
 	it( 'should have stop() and off() marked', function() {
-		var EventInfo = modules.eventinfo;
+		const EventInfo = modules.eventinfo;
 
 		var event = new EventInfo( this, 'test' );
 
@@ -32,7 +32,7 @@ describe( 'EventInfo', function() {
 	} );
 
 	it( 'should not mark "called" in future instances', function() {
-		var EventInfo = modules.eventinfo;
+		const EventInfo = modules.eventinfo;
 
 		var event = new EventInfo( this, 'test' );
 

+ 7 - 7
packages/ckeditor5-ui/tests/mvc/model/model.js

@@ -7,11 +7,11 @@
 
 const modules = bender.amd.require( 'model', 'eventinfo', 'ckeditorerror' );
 
-var Car, car;
+let Car, car;
 
 describe( 'Model', function() {
 	beforeEach( 'Create a test model instance', function() {
-		var Model = modules.model;
+		const Model = modules.model;
 
 		Car = class extends Model {};
 
@@ -81,7 +81,7 @@ describe( 'Model', function() {
 		} );
 
 		it( 'should fire the "change" event', function() {
-			var EventInfo = modules.eventinfo;
+			const EventInfo = modules.eventinfo;
 
 			var spy = sinon.spy();
 			var spyColor = sinon.spy();
@@ -136,7 +136,7 @@ describe( 'Model', function() {
 		} );
 
 		it( 'should throw when overriding already existing property', function() {
-			var CKEditorError = modules.ckeditorerror;
+			const CKEditorError = modules.ckeditorerror;
 
 			car.normalProperty = 1;
 
@@ -148,8 +148,8 @@ describe( 'Model', function() {
 		} );
 
 		it( 'should throw when overriding already existing property (in the prototype)', function() {
-			var CKEditorError = modules.ckeditorerror;
-			var Model = modules.model;
+			const CKEditorError = modules.ckeditorerror;
+			const Model = modules.model;
 
 			class Car extends Model {
 				method() {}
@@ -167,7 +167,7 @@ describe( 'Model', function() {
 
 	describe( 'extend', function() {
 		it( 'should create new Model based classes', function() {
-			var Model = modules.model;
+			const Model = modules.model;
 
 			class Truck extends Car {}
 

+ 4 - 4
packages/ckeditor5-ui/tests/ui/region.js

@@ -12,7 +12,7 @@ const modules = bender.amd.require( 'ckeditor', 'ui/region', 'ui/view', 'collect
 
 bender.tools.createSinonSandbox();
 
-var TestViewA, TestViewB;
+let TestViewA, TestViewB;
 var region, el;
 
 beforeEach( createRegionInstance );
@@ -26,7 +26,7 @@ describe( 'constructor', function() {
 
 describe( 'views collection', function() {
 	it( 'is an instance of Collection', function() {
-		var Collection = modules.collection;
+		const Collection = modules.collection;
 		expect( region.views ).to.be.an.instanceof( Collection );
 	} );
 
@@ -90,8 +90,8 @@ describe( 'destroy', function() {
 } );
 
 function createRegionInstance() {
-	var Region = modules[ 'ui/region' ];
-	var View = modules[ 'ui/view' ];
+	const Region = modules[ 'ui/region' ];
+	const View = modules[ 'ui/view' ];
 
 	class A extends View {
 		constructor() {

+ 1 - 1
packages/ckeditor5-ui/tests/ui/template.js

@@ -9,7 +9,7 @@
 'use strict';
 
 const modules = bender.amd.require( 'ckeditor', 'ui/view', 'ui/template' );
-var Template;
+let Template;
 
 bender.tools.createSinonSandbox();
 beforeEach( createClassReferences );

+ 3 - 3
packages/ckeditor5-ui/tests/ui/view.js

@@ -9,7 +9,7 @@
 'use strict';
 
 const modules = bender.amd.require( 'ckeditor', 'ui/view', 'ui/region', 'ckeditorerror', 'model', 'eventinfo' );
-var View, TestView;
+let View, TestView;
 var view;
 
 bender.tools.createSinonSandbox();
@@ -419,7 +419,7 @@ describe( 'destroy', function() {
 	} );
 
 	it( 'destroys child regions', function() {
-		var Region = modules[ 'ui/region' ];
+		const Region = modules[ 'ui/region' ];
 		var region = new Region( 'test' );
 		var spy = bender.sinon.spy( region, 'destroy' );
 
@@ -486,7 +486,7 @@ function setTestViewInstance( model ) {
 
 function dispatchEvent( el, domEvtName ) {
 	if ( !el.parentNode ) {
-		throw( 'To dispatch an event, element must be in DOM. Otherwise #target is null.' );
+		throw new Error( 'To dispatch an event, element must be in DOM. Otherwise #target is null.' );
 	}
 
 	el.dispatchEvent( new Event( domEvtName, {