Files
ui/test/utils/form.ts
max 95aa6f68b3 feat(PinInput): implement component (#2570)
Co-authored-by: Max Steinwand <msteinwand@kues.de>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
Co-authored-by: Romain Hamel <rom.hml@gmail.com>
2024-11-12 16:11:06 +01:00

57 lines
1.1 KiB
TypeScript

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,
UPinInput
} 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: {
// @ts-expect-error - Object literal may only specify known properties, and setup does not exist in type
setup() {
return { state, ...options.slotVars }
},
components: {
UFormField,
UForm,
UInput,
URadioGroup,
UTextarea,
UCheckbox,
USelect,
USelectMenu,
UInputMenu,
USwitch,
USlider,
UPinInput
},
template: options.slotTemplate
}
}
})
}