Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. I want to mock get Token inside the mocked function in test case by calling from the child component
  2.  
  3. onLocationSubmit = async (start, end) => {
  4. try {
  5. this.setState({ token: false, isLoader: true, errorMessage: "", routeDetail: {}, path: [] });
  6. const response = await getToken({ start, end });
  7. if (response && response.data && response.data.token) {
  8. this.setState({ token: response.data.token }, () => {
  9. this.getDirectionPath();
  10. });
  11. }
  12. } catch (error) {
  13. this.setState({ errorMessage: error.response.data, isLoader: false });
  14. }
  15. };
  16.  
  17. onFormSubmit = event => {
  18. event.preventDefault();
  19. const { onSubmitSearch } = this.props;
  20. const { origin, destination } = this.state;
  21. onSubmitSearch(origin, destination);
  22. this.setState({ isSubmit: true });
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement