From: Eduardo San Martin Morote Date: Thu, 24 Jun 2021 10:34:04 +0000 (+0200) Subject: test: fix type X-Git-Tag: v0.5.3~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aed2cad6cb9e6fdb3f01e486dc591a4627c8260b;p=thirdparty%2Fvuejs%2Fpinia.git test: fix type --- 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()