Преглед на файлове

Tests: Added tests for full coverage.

Aleksander Nowodzinski преди 9 години
родител
ревизия
30234d01b0
променени са 1 файла, в които са добавени 18 реда и са изтрити 0 реда
  1. 18 0
      packages/ckeditor5-utils/tests/emittermixin.js

+ 18 - 0
packages/ckeditor5-utils/tests/emittermixin.js

@@ -679,6 +679,12 @@ describe( 'delegate', () => {
 } );
 
 describe( 'stopDelegating', () => {
+	it( 'passes if no delegation was set', () => {
+		expect( () => {
+			getEmitterInstance().stopDelegating();
+		} ).to.not.throw();
+	} );
+
 	it( 'stops delegating all events to all emitters', () => {
 		const emitterA = getEmitterInstance();
 		const emitterB = getEmitterInstance();
@@ -752,6 +758,18 @@ describe( 'stopDelegating', () => {
 
 		expect( fireLog ).to.deep.equal( [ 'B#foo', 'C#foo', 'B#foo' ] );
 	} );
+
+	it( 'passes when stopping delegation of a specific event to an emitter which wasn\'t a destination', () => {
+		const emitterA = getEmitterInstance();
+		const emitterB = getEmitterInstance();
+		const emitterC = getEmitterInstance();
+
+		emitterA.delegate( 'foo' ).to( emitterB );
+
+		expect( () => {
+			emitterA.stopDelegating( 'foo', emitterC );
+		} ).to.not.throw();
+	} );
 } );
 
 function refreshEmitter() {