mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
test(frontend): add regression test for FormField $attrs event forwarding
Verify that FormField forwards $attrs event listeners (onKeyup, onFocusout) to its inner input element. This ensures migrated templates using @keyup.enter and @focusout continue to work correctly.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {describe, it, expect} from 'vitest'
|
||||
import {describe, it, expect, vi} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import FormField from './FormField.vue'
|
||||
|
||||
@@ -102,6 +102,29 @@ describe('FormField', () => {
|
||||
expect(input.attributes('autocomplete')).toBe('email')
|
||||
})
|
||||
|
||||
it('forwards $attrs event listeners to inner input', async () => {
|
||||
const onKeyup = vi.fn()
|
||||
const onFocusout = vi.fn()
|
||||
|
||||
const wrapper = mount(FormField, {
|
||||
props: {
|
||||
modelValue: 'test',
|
||||
},
|
||||
attrs: {
|
||||
onKeyup,
|
||||
onFocusout,
|
||||
},
|
||||
})
|
||||
|
||||
const input = wrapper.find('input')
|
||||
|
||||
await input.trigger('keyup', {key: 'Enter'})
|
||||
expect(onKeyup).toHaveBeenCalledTimes(1)
|
||||
|
||||
await input.trigger('focusout')
|
||||
expect(onFocusout).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