8
0
فهرست منبع

Code refactoring in Template and View tests.

Aleksander Nowodzinski 9 سال پیش
والد
کامیت
39afacbd9d
2فایلهای تغییر یافته به همراه37 افزوده شده و 37 حذف شده
  1. 23 23
      packages/ckeditor5-engine/tests/ui/template.js
  2. 14 14
      packages/ckeditor5-engine/tests/ui/view.js

+ 23 - 23
packages/ckeditor5-engine/tests/ui/template.js

@@ -19,7 +19,7 @@ let el, text;
 describe( 'Template', () => {
 	describe( 'constructor', () => {
 		it( 'accepts the definition', () => {
-			let def = {
+			const def = {
 				tag: 'p'
 			};
 
@@ -42,7 +42,7 @@ describe( 'Template', () => {
 		} );
 
 		it( 'creates a HTMLElement with attributes', () => {
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				attributes: {
 					'class': [ 'a', 'b' ],
@@ -57,7 +57,7 @@ describe( 'Template', () => {
 		} );
 
 		it( 'creates HTMLElement\'s children', () => {
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				attributes: {
 					a: 'A'
@@ -84,14 +84,14 @@ describe( 'Template', () => {
 		} );
 
 		it( 'creates a Text node', () => {
-			let node = new Template( { text: 'foo' } ).render();
+			const node = new Template( { text: 'foo' } ).render();
 
 			expect( node.nodeType ).to.be.equal( 3 );
 			expect( node.textContent ).to.be.equal( 'foo' );
 		} );
 
 		it( 'creates a child Text Node (different syntaxes)', () => {
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				children: [
 					'foo',
@@ -103,7 +103,7 @@ describe( 'Template', () => {
 		} );
 
 		it( 'creates multiple child Text Nodes', () => {
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				children: [ 'a', 'b', { text: 'c' }, 'd' ]
 			} ).render();
@@ -113,11 +113,11 @@ describe( 'Template', () => {
 		} );
 
 		it( 'activates listener attachers – root', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
-			let spy3 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
+			const spy3 = testUtils.sinon.spy();
 
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				on: {
 					_listenerAttachers: {
@@ -133,8 +133,8 @@ describe( 'Template', () => {
 		} );
 
 		it( 'activates listener attachers – children', () => {
-			let spy = testUtils.sinon.spy();
-			let el = new Template( {
+			const spy = testUtils.sinon.spy();
+			const el = new Template( {
 				tag: 'p',
 				children: [
 					{
@@ -152,12 +152,12 @@ describe( 'Template', () => {
 		} );
 
 		it( 'activates listener attachers – DOM selectors', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
-			let spy3 = testUtils.sinon.spy();
-			let spy4 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
+			const spy3 = testUtils.sinon.spy();
+			const spy4 = testUtils.sinon.spy();
 
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				children: [
 					{
@@ -193,10 +193,10 @@ describe( 'Template', () => {
 		} );
 
 		it( 'activates model bindings – attributes', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
 
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				attributes: {
 					'class': spy1
@@ -221,10 +221,10 @@ describe( 'Template', () => {
 		} );
 
 		it( 'activates model bindings – Text Node', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
 
-			let el = new Template( {
+			const el = new Template( {
 				tag: 'p',
 				children: [
 					{

+ 14 - 14
packages/ckeditor5-engine/tests/ui/view.js

@@ -225,8 +225,8 @@ describe( 'View', () => {
 		it( 'returns a function that passes arguments', () => {
 			setTestViewInstance( { a: 'foo' } );
 
-			let spy = testUtils.sinon.spy();
-			let callback = view.bindToAttribute( 'a', spy );
+			const spy = testUtils.sinon.spy();
+			const callback = view.bindToAttribute( 'a', spy );
 
 			expect( spy.called ).to.be.false;
 
@@ -283,7 +283,7 @@ describe( 'View', () => {
 		} );
 
 		it( 'allows binding to the model with value processing', () => {
-			let callback = ( el, value ) =>
+			const callback = ( el, value ) =>
 				( value > 0 ? 'positive' : 'negative' );
 
 			setTestViewClass( function() {
@@ -334,7 +334,7 @@ describe( 'View', () => {
 
 	describe( 'on', () => {
 		it( 'accepts plain binding', () => {
-			let spy = testUtils.sinon.spy();
+			const spy = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -357,8 +357,8 @@ describe( 'View', () => {
 		} );
 
 		it( 'accepts an array of event bindings', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -386,9 +386,9 @@ describe( 'View', () => {
 		} );
 
 		it( 'accepts DOM selectors', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
-			let spy3 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
+			const spy3 = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -471,8 +471,8 @@ describe( 'View', () => {
 		} );
 
 		it( 'accepts function callbacks', () => {
-			let spy1 = testUtils.sinon.spy();
-			let spy2 = testUtils.sinon.spy();
+			const spy1 = testUtils.sinon.spy();
+			const spy2 = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -504,7 +504,7 @@ describe( 'View', () => {
 		} );
 
 		it( 'supports event delegation', () => {
-			let spy = testUtils.sinon.spy();
+			const spy = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -532,7 +532,7 @@ describe( 'View', () => {
 		} );
 
 		it( 'works for future elements', () => {
-			let spy = testUtils.sinon.spy();
+			const spy = testUtils.sinon.spy();
 
 			setTestViewClass( function() {
 				return {
@@ -547,7 +547,7 @@ describe( 'View', () => {
 
 			view.on( 'a', spy );
 
-			let div = document.createElement( 'div' );
+			const div = document.createElement( 'div' );
 			view.element.appendChild( div );
 
 			dispatchEvent( div, 'test' );