import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
// Smoke-test helper. Vuetify components are left unresolved (Vue 3 renders
// unknown elements with their slot children, so text content is still
// present and nothing throws), which avoids standing up the whole Vuetify
// plugin in happy-dom. RouterLink is the one import that needs a router, so
// it's stubbed with a slot-rendering anchor.
export function freshPinia () {
const pinia = createPinia()
setActivePinia(pinia)
return pinia
}
// `stubs` is merged over the defaults. Needed whenever the component under
// test puts content in a NAMED slot of a Vuetify component: leaving those
// unresolved renders default-slot children only, so a named slot (v-tooltip's
// `#activator`, say) silently renders nothing and assertions find an empty
// wrapper rather than failing loudly.
export function mountComponent (Component, { props = {}, pinia, stubs = {} } = {}) {
return mount(Component, {
props,
global: {
plugins: pinia ? [pinia] : [],
stubs: { RouterLink: { template: '