From df759603a9ece008683cfb9b6a5e5d7c1ce761d1 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 23 Apr 2023 12:43:04 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20(utils)=20more=20flexible=20withPlu?= =?UTF-8?q?gins=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tests/utils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tests/utils.ts b/src/tests/utils.ts index f754c23..61c446a 100644 --- a/src/tests/utils.ts +++ b/src/tests/utils.ts @@ -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, + global?: Partial +): { global: GlobalMountOptions } => ({ global: { + ...global, plugins: [ createTestingPinia({ createSpy: vi.fn, initialState: { - ...partialState, - ...initialState + ...initialState, + ...partialState } }), router