I have some difficulty in understanding how to test my action inside a function:
componentDidMount() {
$.ajax(
{
url: this.props.url,
dataType: 'json',
cache: false,
success: function (data) {
if (this.props.url === "./information.json")
this.props.updateInfosAction(data.transport);
else
this.props.updateNotifsAction(data.transport);
}.bind(this),
error: function (xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
}
);
}
Here is my test to be sure that ComponentDidMount
is called (it works):
it('Should call component did mount', () => {
expect(GetInfo.prototype.componentDidMount.calledOnce);
});
But I have no idea how to actually test the action.
Aucun commentaire:
Enregistrer un commentaire