Browse Source

Added a test to ensure that stopListening() doesn't get confused when non listened emitters are passed to it.

fredck 10 years ago
parent
commit
6724ef77b2
1 changed files with 15 additions and 0 deletions
  1. 15 0
      packages/ckeditor5-utils/tests/emitter/emitter.js

+ 15 - 0
packages/ckeditor5-utils/tests/emitter/emitter.js

@@ -355,6 +355,21 @@ describe( 'stopListening', function() {
 
 		expect( listener ).to.not.have.property( '_listeningTo' );
 	} );
+
+	it( 'should not stop other emitters when a non-listened emitter is provided', function() {
+		var spy = sinon.spy();
+
+		var emitter1 = getEmitterInstance();
+		var emitter2 = getEmitterInstance();
+
+		listener.listenTo( emitter1, 'test', spy );
+
+		listener.stopListening( emitter2 );
+
+		emitter1.fire( 'test' );
+
+		sinon.assert.called( spy );
+	} );
 } );
 
 function refreshEmitter() {