Files
ui/test/component-render.ts
Benjamin Canac 290e4ce150 test: lint
2024-04-12 14:00:58 +02:00

20 lines
587 B
TypeScript

import path from 'node:path'
import { mountSuspended } from '@nuxt/test-utils/runtime'
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
}