jeudi 19 janvier 2017

React Test. how to set function inside react component

What is the proper way to test a method within a react component, in this case componentDidMount. I want to test the setTimeOut function inside the compoenent. Should I use stub? For example the code below:

 componentDidMount() {
        setTimeOut(() => this.setState({ isOpen: true }), 1);
  }

How can I test the setTimeOut being called?

Aucun commentaire:

Enregistrer un commentaire