mardi 16 juillet 2019

How I can unit test componentWillReceiveProps(nextProps) with jest?

How cand I unit test componentWillReceiveProps(nextProps) with jest?

componentWillReceiveProps(nextProps) {
    if (nextProps.data === undefined || 
        nextProps.data.hasOwnProperty('error') || 
        nextProps.err !== undefined) {
        this.setState({
        messageError: "Something went wrong!"
        });
    }  else if ((nextProps.data).length) {
        this.setState({
            dataArray: nextProps.data
        });
    }  
}

Aucun commentaire:

Enregistrer un commentaire