@@ -5,27 +5,26 @@ import Login from './components/Login'
55test ( 'login form submits' , ( ) => {
66 const fakeUser = { username : 'jackiechan' , password : 'hiya! 🥋' }
77 const handleSubmit = jest . fn ( )
8- const { wrapper , getByLabelText, getByText} = render (
8+ const { updateState , getByLabelText, getByText} = render (
99 Login , { props : { onSubmit : handleSubmit } }
1010 )
1111
1212 const usernameNode = getByLabelText ( 'username' )
1313 const passwordNode = getByLabelText ( 'password' )
14- const formNode = wrapper . find ( 'form' )
1514 const submitButtonNode = getByText ( 'submit' )
1615
1716 // Act - this is waiting on an issue in @vue/test-utils to allow v-model to be updated by
1817 // changes to DOM elements
19-
18+
2019 // Simulate.change(usernameNode, fakeUser.username)
2120 // Simulate.change(passwordNode, fakeUser.password)
22- wrapper . setData ( fakeUser )
21+ updateState ( fakeUser )
2322
2423 // NOTE: in jsdom, it's not possible to trigger a form submission
2524 // by clicking on the submit button. This is really unfortunate.
2625 // So the next best thing is to simulate a submit on the form itself
2726 // then ensure that there's a submit button.
28- Simulate . submit ( formNode )
27+ Simulate . click ( submitButtonNode )
2928
3029 // Assert
3130 expect ( handleSubmit ) . toHaveBeenCalledTimes ( 1 )
0 commit comments