Folks,
Front-end newb here. Trying to understand how to properly pass mock props to a constructor of a component....
class MyComponent extends React.Component {
constructor(props) {
super(props);
let dataToDecode = QueryString.parse(props.location.search).data;
const data = QueryString.parse(Base64.decode(dataToDecode));
this.state = {
email: data.email,
...
};
...
So how does one mock the props in react? can testing-library/react or jest help with this?
i.e. the tests need to cover proper uri and an incorrect one.
https://domain/path?data=somebase64encodedstring
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<MyComponent />, div);
});
thanks!