Files
ui/test/component-render.ts
Romain Hamel de62676647 feat(Form): new component (#4)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2024-03-19 16:09:12 +01:00

20 lines
582 B
TypeScript

import { mountSuspended } from '@nuxt/test-utils/runtime'
import path from 'path'
export default async function (nameOrHtml: string, options: any, component: any) {
let html: string
const name = component.__file ? path.parse(component.__file).name : undefined
if (options === undefined) {
const app = {
template: nameOrHtml,
components: { [`U${name}`]: component }
}
const result = await mountSuspended(app)
html = result.html()
} else {
const cResult = await mountSuspended(component, options)
html = cResult.html()
}
return html
}