Guest User

Untitled

a guest
Nov 9th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. _onSubmit = (event) => {
  2. event.preventDefault()
  3. const { username, password } = this.state
  4.  
  5. this.props.createUserMutation({
  6. variables: { username, password }
  7. }).then(response => {
  8. this.setState({
  9. username: '',
  10. password: ''
  11. })
  12. }).catch(error => {
  13. console.warn(error)
  14. })
  15. }
  16.  
  17. it('_onSubmit() should submit form and reset state object', () => {
  18. const wrapper = shallow(<CreateAccount />)
  19. wrapper.setState({ username: 'Username', password: 'Password' })
  20. wrapper.find(Form).simulate('submit', {
  21. preventDefault: () => {}
  22. })
  23. const state = wrapper.instance().state
  24. expect(state).toEqual({ username: '', password: '' })
  25. })
Add Comment
Please, Sign In to add comment