From ef7b29c185cd3d971824a5c66e3b7289f75b13e9 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 18 Feb 2022 23:57:36 +0100 Subject: [PATCH] test: refactor --- .../pinia/__tests__/multipleRoots.spec.ts | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/packages/pinia/__tests__/multipleRoots.spec.ts b/packages/pinia/__tests__/multipleRoots.spec.ts index 3efdcfe6ef..bfd318301f 100644 --- a/packages/pinia/__tests__/multipleRoots.spec.ts +++ b/packages/pinia/__tests__/multipleRoots.spec.ts @@ -4,8 +4,7 @@ import { defineComponent } from 'vue' describe('Multiple Roots', () => { function defineMyStore() { - return defineStore({ - id: 'main', + return defineStore('main', { state: () => ({ n: 0, }), @@ -13,7 +12,6 @@ describe('Multiple Roots', () => { } it('uses the same root in child components by default', () => { - expect.assertions(2) const pinia = createPinia() const useStore = defineMyStore() @@ -37,10 +35,12 @@ describe('Multiple Roots', () => { }, { global: { plugins: [pinia] } } ) + + const store = useStore() + expect(store.n).toBe(1) }) it('can use a new pinia root for all child components', async () => { - expect.assertions(2) const pinia = createPinia() const useStore = defineMyStore() @@ -64,35 +64,8 @@ describe('Multiple Roots', () => { }, { global: { plugins: [pinia] } } ) - }) - - it('state is shared between child components', async () => { - expect.assertions(3) - const pinia = createPinia() - const useStore = defineMyStore() - const ChildComponent = defineComponent({ - template: 'no', - props: { counter: { type: Number, required: true } }, - setup(props: { counter: number }) { - const store = useStore() - expect(store.n).toBe(props.counter) - store.n++ - }, - }) - mount( - { - template: - '', - components: { ChildComponent }, - setup() { - const store = useStore() - expect(store.n).toBe(0) - store.n++ - providePinia(createPinia()) - }, - }, - { global: { plugins: [pinia] } } - ) + const store = useStore() + expect(store.n).toBe(0) }) })