mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
test: setup
This commit is contained in:
19
test/components/component-render.ts
Normal file
19
test/components/component-render.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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 = path.parse(component.__file).name
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user