From: Eduardo San Martin Morote Date: Thu, 24 Jun 2021 10:34:04 +0000 (+0200) Subject: test: fix type X-Git-Tag: v2.0.0-beta.5~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d340b9c12369affbc89e52c82f2fd785f08d444d;p=thirdparty%2Fvuejs%2Fpinia.git test: fix type --- diff --git a/__tests__/storePlugins.spec.ts b/__tests__/storePlugins.spec.ts index cc5d17a1..a6d7b8b0 100644 --- a/__tests__/storePlugins.spec.ts +++ b/__tests__/storePlugins.spec.ts @@ -1,6 +1,6 @@ import { createPinia, defineStore } from '../src' import { mount } from '@vue/test-utils' -import { App } from 'vue' +import { App, ref, toRef } from 'vue' declare module '../src' { export interface PiniaCustomProperties { @@ -11,6 +11,11 @@ declare module '../src' { globalA: string globalB: string } + + export interface PiniaCustomStateProperties { + // pluginN: 'test' extends Id ? number : never | undefined + pluginN: number + } } describe('store plugins', () => { @@ -34,8 +39,15 @@ describe('store plugins', () => { mount({ template: 'none' }, { global: { plugins: [pinia] } }) // must call use after installing the plugin - pinia.use(({ app }) => { - return { pluginN: 20, uid: app._uid } + pinia.use(({ app, store }) => { + if (!('pluginN' in store.$state)) { + // @ts-expect-error: the check above makes this impossible + // but in practice we need this until effectScope is released + store.$state.pluginN = ref(20) + } + // @ts-expect-error: TODO: allow setting refs + store.pluginN = toRef(store.$state, 'pluginN') + return { uid: app._uid } }) const store = useStore(pinia)