mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-02-01 22:47:40 +00:00
test(frontend): add test for @keyup.enter forwarding in FormField
Verify that @keyup.enter modifier is properly forwarded to the inner input element and only triggers for Enter key, not other keys.
This commit is contained in:
@@ -125,6 +125,28 @@ describe('FormField', () => {
|
||||
expect(onFocusout).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('forwards @keyup.enter to inner input', async () => {
|
||||
const onSubmit = vi.fn()
|
||||
|
||||
const wrapper = mount({
|
||||
components: {FormField},
|
||||
template: `<FormField @keyup.enter="onSubmit" />`,
|
||||
setup() {
|
||||
return {onSubmit}
|
||||
},
|
||||
})
|
||||
|
||||
const input = wrapper.find('input')
|
||||
|
||||
// Enter key should trigger the handler
|
||||
await input.trigger('keyup', {key: 'Enter'})
|
||||
expect(onSubmit).toHaveBeenCalledTimes(1)
|
||||
|
||||
// Other keys should not trigger the handler
|
||||
await input.trigger('keyup', {key: 'a'})
|
||||
expect(onSubmit).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('uses provided id for input', () => {
|
||||
const wrapper = mount(FormField, {
|
||||
props: {id: 'my-input', label: 'My Input'},
|
||||
|
||||
Reference in New Issue
Block a user