Files
Francesco Mussoni cba2c2c40c feat(InputRating): new component (#5757)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2026-06-25 17:31:18 +02:00

77 lines
1.7 KiB
TypeScript

import { reactive } from 'vue'
import type { 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,
UInputNumber,
USwitch,
USlider,
UPinInput,
UCheckboxGroup,
UFileUpload,
UInputRating,
UListbox
} from '#components'
export async function renderForm(options: {
state?: Reactive<any>
props?: Partial<FormProps<any>> & Record<string, any>
slotVars?: object
slotTemplate?: string
fixture?: string
}) {
const state = options.state ?? reactive({})
if (options.fixture) {
const fixture = await import(/* @vite-ignore */ `../components/fixtures/${options.fixture}.vue`).then(c => c.default)
return await mountSuspended(fixture, {
props: options.props
})
}
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,
UInputNumber,
USwitch,
USlider,
UPinInput,
UCheckboxGroup,
UFileUpload,
UInputRating,
UListbox
},
template: options.slotTemplate
}
}
})
}