mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
refactor(Form): input events (#99)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
53
test/utils/form.ts
Normal file
53
test/utils/form.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { reactive } from 'vue'
|
||||
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
||||
import type { FormProps } from '../../src/runtime/components/Form.vue'
|
||||
import {
|
||||
UForm,
|
||||
UInput,
|
||||
UFormField,
|
||||
URadioGroup,
|
||||
UTextarea,
|
||||
UCheckbox,
|
||||
USelect,
|
||||
USelectMenu,
|
||||
UInputMenu,
|
||||
USwitch,
|
||||
USlider
|
||||
} from '#components'
|
||||
|
||||
export async function renderForm(options: {
|
||||
props: Partial<FormProps<any>>
|
||||
slotVars?: object
|
||||
slotTemplate: string
|
||||
}) {
|
||||
const state = reactive({})
|
||||
|
||||
return await mountSuspended(UForm, {
|
||||
props: {
|
||||
id: 42,
|
||||
state,
|
||||
...options.props
|
||||
},
|
||||
slots: {
|
||||
default: {
|
||||
setup() {
|
||||
return { state, ...options.slotVars }
|
||||
},
|
||||
components: {
|
||||
UFormField,
|
||||
UForm,
|
||||
UInput,
|
||||
URadioGroup,
|
||||
UTextarea,
|
||||
UCheckbox,
|
||||
USelect,
|
||||
USelectMenu,
|
||||
UInputMenu,
|
||||
USwitch,
|
||||
USlider
|
||||
},
|
||||
template: options.slotTemplate
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user