I want to test that clearInterval()
has been called on componentWillUnmount()
. How do I set a spy on clearInterval()
?
it("should unmount", () => {
const wrapper = shallow(<MessageLoaderWrapper messageList={messageList} />);
wrapper.unmount();
expect(wrapper.find(".tabs-infinite-loader--message").length).to.equal(0);
});
Currently testing that a className is no longer there; but really should be testing that clearInterval()
was called.
Global functions can be spied on window
or global
, depending on the environment, e.g.:
sinon.spy(global, 'clearInterval');
...
expect(clearInterval).to.have.been.calledOnce;