Buna, am nevoie de ajutor. Vreau sa testez componenta
describe('<Component entityType="USER"/>', () => {
it('renders three <Component entityType="USER"/> components', () => {
const app = shallow(<Component entityType="USER"/>);
expect(app.containsMatchingElement(Gallery)).to.be.true;
});
});
Incerc sa vad daca componenta face render cum trebuie. Componenta arata astfel:
constructor(props) {
super(props);
this.state = {
loading: false,
uploader: null,
};
}
componentWillMount() {
const { entityType } = this.props;
// Get temp credentials and init uploader
return axios.post(`${URL}/getTempS3Credentials`, {
entityType: entityType,
}).then((credentials) => {
const uploader = this.initUploader(credentials);
this.setState({loading: true, uploader: uploader });
})
}
render() {
return (
<div>
{ this.state.loading && <Gallery uploader={ this.state.uploader } /> }
</div>
)
}
Problema e ca testul returneaza numai <div></div>
, nu asteapta sa faca componentWillMount si sa faca rerender la componenta.