Browse Source

Added utils for testing CKEditor errors.

Maciej Bukowski 6 years ago
parent
commit
b5d163c0df

+ 53 - 48
packages/ckeditor5-utils/tests/_utils-tests/utils.js

@@ -3,76 +3,81 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import utilsTestUtils from '../../tests/_utils/utils';
-import ObesrvableMixin from '../../src/observablemixin';
+import * as testUtils from '../../tests/_utils/utils';
+import ObservableMixin from '../../src/observablemixin';
 import EmitterMixin from '../../src/emittermixin';
 
-describe( 'utilsTestUtils.createObserver()', () => {
-	let observable, observable2, observer;
+describe( 'utils - testUtils', () => {
+	afterEach( () => {
+		sinon.restore();
+	} );
 
-	testUtils.createSinonSandbox();
+	describe( 'createObserver()', () => {
+		let observable, observable2, observer;
 
-	beforeEach( () => {
-		observer = utilsTestUtils.createObserver();
+		testUtils.createSinonSandbox();
 
-		observable = Object.create( ObesrvableMixin );
-		observable.set( { foo: 0, bar: 0 } );
+		beforeEach( () => {
+			observer = testUtils.createObserver();
 
-		observable2 = Object.create( ObesrvableMixin );
-		observable2.set( { foo: 0, bar: 0 } );
-	} );
+			observable = Object.create( ObservableMixin );
+			observable.set( { foo: 0, bar: 0 } );
 
-	it( 'should create an observer', () => {
-		function Emitter() {}
-		Emitter.prototype = EmitterMixin;
+			observable2 = Object.create( ObservableMixin );
+			observable2.set( { foo: 0, bar: 0 } );
+		} );
 
-		expect( observer ).to.be.instanceof( Emitter );
-		expect( observer.observe ).is.a( 'function' );
-		expect( observer.stopListening ).is.a( 'function' );
-	} );
+		it( 'should create an observer', () => {
+			function Emitter() { }
+			Emitter.prototype = EmitterMixin;
 
-	describe( 'Observer', () => {
-		/* global console:false  */
+			expect( observer ).to.be.instanceof( Emitter );
+			expect( observer.observe ).is.a( 'function' );
+			expect( observer.stopListening ).is.a( 'function' );
+		} );
 
-		it( 'logs changes in the observable', () => {
-			const spy = testUtils.sinon.stub( console, 'log' );
+		describe( 'Observer', () => {
+			/* global console:false  */
 
-			observer.observe( 'Some observable', observable );
-			observer.observe( 'Some observable 2', observable2 );
+			it( 'logs changes in the observable', () => {
+				const spy = sinon.stub( console, 'log' );
 
-			observable.foo = 1;
-			expect( spy.callCount ).to.equal( 1 );
+				observer.observe( 'Some observable', observable );
+				observer.observe( 'Some observable 2', observable2 );
 
-			observable.foo = 2;
-			observable2.bar = 3;
-			expect( spy.callCount ).to.equal( 3 );
-		} );
+				observable.foo = 1;
+				expect( spy.callCount ).to.equal( 1 );
 
-		it( 'logs changes to specified properties', () => {
-			const spy = testUtils.sinon.stub( console, 'log' );
+				observable.foo = 2;
+				observable2.bar = 3;
+				expect( spy.callCount ).to.equal( 3 );
+			} );
 
-			observer.observe( 'Some observable', observable, [ 'foo' ] );
+			it( 'logs changes to specified properties', () => {
+				const spy = sinon.stub( console, 'log' );
 
-			observable.foo = 1;
-			expect( spy.callCount ).to.equal( 1 );
+				observer.observe( 'Some observable', observable, [ 'foo' ] );
 
-			observable.bar = 1;
-			expect( spy.callCount ).to.equal( 1 );
-		} );
+				observable.foo = 1;
+				expect( spy.callCount ).to.equal( 1 );
+
+				observable.bar = 1;
+				expect( spy.callCount ).to.equal( 1 );
+			} );
 
-		it( 'stops listening when asked to do so', () => {
-			const spy = testUtils.sinon.stub( console, 'log' );
+			it( 'stops listening when asked to do so', () => {
+				const spy = sinon.stub( console, 'log' );
 
-			observer.observe( 'Some observable', observable );
+				observer.observe( 'Some observable', observable );
 
-			observable.foo = 1;
-			expect( spy.callCount ).to.equal( 1 );
+				observable.foo = 1;
+				expect( spy.callCount ).to.equal( 1 );
 
-			observer.stopListening();
+				observer.stopListening();
 
-			observable.foo = 2;
-			expect( spy.callCount ).to.equal( 1 );
+				observable.foo = 2;
+				expect( spy.callCount ).to.equal( 1 );
+			} );
 		} );
 	} );
 } );

+ 1 - 1
packages/ckeditor5-utils/tests/_utils/utils.js

@@ -18,7 +18,7 @@ import areConnectedThroughProperties from '../../src/areconnectedthroughproperti
  * * `{String} observableName` – Identifier for the observable object. E.g. `"Editable"` when
  * you observe one of editor's editables. This name will be displayed on the console.
  * * `{utils.Observable observable} – The object to observe.
- * * `{Array.<String>} filterNames` – Array of propery names to be observed.
+ * * `{Array.<String>} filterNames` – Array of property names to be observed.
  *
  * Typical usage:
  *