Good day, fellow earthlings!
I have this React component and it have method that calls clearInterval to clear the interval set by other method
class SomeComponent extends React.Component {
setIntervalMethod = () => {
this.interval = setInterval(this.method, 1000)
}
claerIntervalMethod = () => {
clearInterval(this.interval)
}
render = () => null
}
How do i test those method?
I've been googling for days, tried using jest.useFakeTimers() and call expect(clearInterval).toHaveBeenCalledWith(expect.any(Function), 1000) and a lot of other absurd way to test this method that i forgot, all to no avail.
So ... if anybody have a solution and kind enough to share here, i could pass this weekend with a happy smiling face and a heart full of joy.
Thanks before. Cheers!
Aucun commentaire:
Enregistrer un commentaire