Use spies as listeners

This commit is contained in:
Per Liedman 2016-08-24 09:52:29 +02:00
parent 0c6dc2ce1e
commit 59c6bb201c

View File

@ -344,22 +344,22 @@ describe('Events', function () {
it('handles reentrant event firing', function () { it('handles reentrant event firing', function () {
var obj = new L.Evented(), var obj = new L.Evented(),
spy = sinon.spy(); spy1 = sinon.spy(),
spy2 = sinon.spy();
obj obj
.addEventListener('test1', function () { .addEventListener('test1', function () {
obj.fire('test2'); obj.fire('test2');
}) })
.addEventListener('test2', function () { .addEventListener('test2', spy1)
// NOP, just to make sure event actually fires
})
.addEventListener('test1', function () { .addEventListener('test1', function () {
obj.removeEventListener('test1', spy); obj.removeEventListener('test1', spy2);
}) })
.addEventListener('test1', spy); .addEventListener('test1', spy2);
obj.fireEvent('test1'); obj.fireEvent('test1');
expect(spy.called).to.be(false); expect(spy1.called).to.be(true);
expect(spy2.called).to.be(false);
}); });
}); });