浏览代码

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

fredck 10 年之前
父节点
当前提交
6724ef77b2
共有 1 个文件被更改,包括 15 次插入0 次删除
  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() {