mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-12-06 07:34:00 +00:00
Install @perfect-design/ui 0.3.10 with the workbench style pack, IBM Plex faces and the inline theme boot script. The app shell uses AppHeader, AppShell and SidebarNav. Shared formatters, severity tones and icon data replace the per-view copies. A test checks that main.css scans only the library directories the app imports.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { configureStrictMode } from '@perfect-design/ui'
|
|
import { flushPromises, mount, type ComponentMountingOptions } from '@vue/test-utils'
|
|
import { vi } from 'vitest'
|
|
import type { Component } from 'vue'
|
|
|
|
/**
|
|
* Mounts under strict mode 'throw' and returns every Vue warning, Vue error and library ContractError seen,
|
|
* so a smoke test can assert the list is empty. The library runs its contract checks from async onMounted hooks.
|
|
*/
|
|
export async function mountStrict(component: Component, options: ComponentMountingOptions<any> = {}) {
|
|
configureStrictMode('throw')
|
|
const problems: string[] = []
|
|
const record = (kind: string) => (err: unknown) => {
|
|
problems.push(`${kind}: ${err instanceof Error ? err.message : String(err)}`)
|
|
}
|
|
const warn = vi.spyOn(console, 'warn').mockImplementation((...args) => record('warn')(args.join(' ')))
|
|
const error = vi.spyOn(console, 'error').mockImplementation((...args) => record('error')(args.join(' ')))
|
|
|
|
const wrapper = mount(component, {
|
|
attachTo: document.body,
|
|
...options,
|
|
global: {
|
|
...options.global,
|
|
config: { errorHandler: record('error'), warnHandler: record('warn') },
|
|
},
|
|
})
|
|
await flushPromises()
|
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
await flushPromises()
|
|
|
|
const restore = () => {
|
|
wrapper.unmount()
|
|
warn.mockRestore()
|
|
error.mockRestore()
|
|
}
|
|
return { wrapper, problems, restore }
|
|
}
|