i am asked to write a unitTest for the following reactjs page.
export default class Collapsible extends React.Component {
static propTypes = {
title: React.PropTypes.string,
children: React.PropTypes.any,
};
render() {
const { title } = this.props;
return (
<details>
<summary>{title}</summary>
{this.props.children}
</details>
);
}
}
Following the tut Here I wrote my test below like
describe('Collapsible', ()=>{
it('works', ()=>{
let renderer = createRenderer();
renderer.render(<Collapsible title="MyTitle"><span>HEllo</span></Collapsible>);
let actualElement = renderer.getRenderOutput();
let expectedElement = (<details><summary>title</summary>Details</details>);
expect(actualElement).toEqual(expectedElement);
});
});
However, my test is throwing the error in the title above, i am suspecting my props on the Collapsible (i.e title and children) are not assigning from the test . Please how do i address this? Any help or guidance would highly be appreciated.
Aucun commentaire:
Enregistrer un commentaire