Skip to content

Commit 8625058

Browse files
AndyAndy
authored andcommitted
ending
1 parent f1a4b51 commit 8625058

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/unit/LoginForm.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import LoginForm from '@/components/LoginForm.vue'
2+
import { mount } from '@vue/test-utils'
3+
4+
describe('LoginForm', () => {
5+
it('emits an event with user data payload', () => {
6+
const wrapper = mount(LoginForm)
7+
const input = wrapper.find('input[type="text"]') // Find text input
8+
9+
input.setValue('Adam Jahr') // Set value for text input
10+
wrapper.trigger('submit') // Simulate form submission
11+
12+
// Assert event has been emitted
13+
const formSubmittedCalls = wrapper.emitted('formSubmitted')
14+
expect(formSubmittedCalls).toHaveLength(1)
15+
16+
// Assert payload is correct
17+
const expectedPayload = { name: 'Adam Jahr' }
18+
expect(wrapper.emitted('formSubmitted')[0][0]).toMatchObject(
19+
expectedPayload
20+
)
21+
})
22+
})

0 commit comments

Comments
 (0)