I could do it with sinon. Here is my solution:
it('adds listener events', function() { sinon.spy(document, 'addEventListener') sinon.spy(window, 'addEventListener') expect(document.addEventListener.calledOnce).not.to.be.true expect(window.addEventListener.calledOnce).not.to.be.true subject.myFunc() expect(document.addEventListener.calledOnce).to.be.true expect(window.addEventListener.calledOnce).to.be.true })
In my case, I had to check the focus window and the click document, for example.
Hope this helps
source share