From: Eduardo San Martin Morote Date: Fri, 19 Nov 2021 09:49:28 +0000 (+0100) Subject: test: add failing skipped test for storeToRefs and reactive X-Git-Tag: @pinia/testing@0.0.6~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2eef8bd30572e7a5e956b0b6ae8724ae15b3f2da;p=thirdparty%2Fvuejs%2Fpinia.git test: add failing skipped test for storeToRefs and reactive --- diff --git a/packages/pinia/__tests__/storeToRefs.spec.ts b/packages/pinia/__tests__/storeToRefs.spec.ts index 6b5eed17..eb7e1d6d 100644 --- a/packages/pinia/__tests__/storeToRefs.spec.ts +++ b/packages/pinia/__tests__/storeToRefs.spec.ts @@ -1,4 +1,4 @@ -import { computed, ref, ToRefs } from 'vue' +import { computed, reactive, ref, ToRefs } from 'vue' import { createPinia, defineStore, setActivePinia, storeToRefs } from '../src' describe('storeToRefs', () => { @@ -45,6 +45,45 @@ describe('storeToRefs', () => { expect(d.value).toBe('e') }) + it.skip('setup store', () => { + const store = defineStore('a', () => { + return { + a: ref(null), + b: ref(false), + c: ref(1), + d: ref('d'), + r: reactive({ n: 1 }), + } + })() + + const { a, b, c, d, r } = storeToRefs(store) + + expect(a.value).toBe(null) + expect(b.value).toBe(false) + expect(c.value).toBe(1) + expect(d.value).toBe('d') + expect(r.value).toEqual({ n: 1 }) + + a.value = undefined + expect(a.value).toBe(undefined) + + b.value = true + expect(b.value).toBe(true) + + c.value = 2 + expect(c.value).toBe(2) + + d.value = 'e' + expect(d.value).toBe('e') + + r.value.n++ + expect(r.value).toEqual({ n: 2 }) + expect(store.r).toEqual({ n: 2 }) + store.r.n++ + expect(r.value).toEqual({ n: 2 }) + expect(store.r).toEqual({ n: 2 }) + }) + it('empty getters', () => { expect( storeToRefs(