✅ (utils) more flexible withPlugins function
This commit is contained in:
@@ -4,6 +4,7 @@ import type { TaskStoreState } from '@/modules/task/stores/useTask.store'
|
||||
import { router } from '@/router'
|
||||
import { toISODate } from '@/shared/types/date'
|
||||
import { createTestingPinia } from '@pinia/testing'
|
||||
import type { GlobalMountOptions } from '@vue/test-utils/dist/types'
|
||||
import { vi } from 'vitest'
|
||||
|
||||
export interface InitialState {
|
||||
@@ -35,14 +36,18 @@ const initialState: InitialState = {
|
||||
}
|
||||
}
|
||||
|
||||
export const withPlugins = (partialState?: TaskStoreState) => ({
|
||||
export const withPlugins = (
|
||||
partialState?: Partial<InitialState>,
|
||||
global?: Partial<GlobalMountOptions>
|
||||
): { global: GlobalMountOptions } => ({
|
||||
global: {
|
||||
...global,
|
||||
plugins: [
|
||||
createTestingPinia({
|
||||
createSpy: vi.fn,
|
||||
initialState: {
|
||||
...partialState,
|
||||
...initialState
|
||||
...initialState,
|
||||
...partialState
|
||||
}
|
||||
}),
|
||||
router
|
||||
|
||||
Reference in New Issue
Block a user