I want to test react component:
export class IdentityPage extends React.Component<PageProps, State> {
constructor(props: PageProps) {
super(props);
}
componentDidMount() { this.reload(this.props.routeParams.id); }
render(){....}
}
which is used in react router like this:
<Router history={hashHistory}>
<Route path="/">
<Route path="Identities">
<Route path=":action/:id" component={IdentityPage} />
</Route>
</Route>
</Router>
However, the test fails with:
Cannot read property 'id' of undefined
when I try to run:
let pageProps: PageProps = {
params: {
action: "view",
id: "0"
}
};
let instance = TestUtils.renderIntoDocument(React.createElement(IdentityPage, pageProps));