From aed2cad6cb9e6fdb3f01e486dc591a4627c8260b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 24 Jun 2021 12:34:04 +0200 Subject: [PATCH] test: fix type --- __tests__/storePlugins.spec.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/__tests__/storePlugins.spec.ts b/__tests__/storePlugins.spec.ts index 4bd9431b..b74050e2 100644 --- a/__tests__/storePlugins.spec.ts +++ b/__tests__/storePlugins.spec.ts @@ -1,6 +1,6 @@ import { createPinia, defineStore, PiniaPlugin } from '../src' import { createLocalVue, mount } from '@vue/test-utils' -import { ref, set } from '@vue/composition-api' +import { ref, set, toRef } from '@vue/composition-api' declare module '../src' { export interface PiniaCustomProperties { @@ -10,6 +10,12 @@ declare module '../src' { idFromPlugin: Id someRef: number } + + export interface PiniaCustomStateProperties { + // pluginN: 'test' extends Id ? number : never | undefined + pluginN: number + someRef: number + } } describe('store plugins', () => { @@ -34,8 +40,13 @@ describe('store plugins', () => { mount({ template: '

' }, { localVue, pinia }) // must call use after installing the plugin - pinia.use(() => { - return { pluginN: 20 } + pinia.use(({ store }) => { + if (!('pluginN' in store.$state)) { + // the check above makes this impossible + // but in practice we need this until effectScope is released + set(store.$state, 'pluginN', ref(20)) + } + set(store, 'pluginN', toRef(store.$state, 'pluginN')) }) const store = useStore() -- 2.47.3