From: Eduardo San Martin Morote Date: Mon, 3 May 2021 09:41:43 +0000 (+0200) Subject: test: refactor plugin tests X-Git-Tag: v0.4.0~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c149982aefd2b1960d44208835b9cd5c6c68fd79;p=thirdparty%2Fvuejs%2Fpinia.git test: refactor plugin tests --- diff --git a/__tests__/storePlugins.spec.ts b/__tests__/storePlugins.spec.ts index 62b50849..91785256 100644 --- a/__tests__/storePlugins.spec.ts +++ b/__tests__/storePlugins.spec.ts @@ -33,14 +33,14 @@ describe('store plugins', () => { it('adds properties to stores', () => { const pinia = createPinia() pinia.Vue = Vue - mount({ template: '

' }, { localVue }) + mount({ template: '

' }, { localVue, pinia }) // must call use after installing the plugin pinia.use(() => { return { n: 20 } }) - const store = useStore(pinia) + const store = useStore() expect(store.n).toBe(20) // @ts-expect-error: n is a number @@ -56,11 +56,11 @@ describe('store plugins', () => { pinia.use(() => ({ n: 1 })) pinia.use((pinia) => ({ hasPinia: !!pinia })) - mount({ template: '

' }, { localVue }) + mount({ template: '

' }, { localVue, pinia }) pinia.use((app) => ({ hasPinia: !!app })) - const store = useStore(pinia) + const store = useStore() expect(store.n).toBe(1) expect(store.hasPinia).toBe(true) @@ -69,14 +69,14 @@ describe('store plugins', () => { it('can be used in actions', () => { const pinia = createPinia() pinia.Vue = Vue - mount({ template: '

' }, { localVue }) + mount({ template: '

' }, { localVue, pinia }) // must call use after installing the plugin pinia.use(() => { return { n: 20 } }) - const store = useStore(pinia) + const store = useStore() expect(store.incrementN()).toBe(20) }) @@ -84,14 +84,14 @@ describe('store plugins', () => { it('can be used in getters', () => { const pinia = createPinia() pinia.Vue = Vue - mount({ template: '

' }, { localVue }) + mount({ template: '

' }, { localVue, pinia }) // must call use after installing the plugin pinia.use(() => { return { n: 20 } }) - const store = useStore(pinia) + const store = useStore() expect(store.doubleN).toBe(40) }) })