]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: fix lifespan test
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 8 Jul 2021 08:50:34 +0000 (10:50 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 19 Jul 2021 09:51:12 +0000 (11:51 +0200)
__tests__/lifespan.spec.ts

index 1ab83bd58d260c78ad4fe8245c17482afe6a51c5..1b589a771095df2a47dcf92d3597bd9ff0ab7d2c 100644 (file)
@@ -1,6 +1,6 @@
 import { createPinia, defineStore, setActivePinia } from '../src'
 import { mount } from '@vue/test-utils'
-import { watch, nextTick, defineComponent, ref, Ref } from 'vue'
+import { watch, nextTick, defineComponent, ref, Ref, onMounted } from 'vue'
 
 describe('Store Lifespan', () => {
   function defineMyStore() {
@@ -38,7 +38,9 @@ describe('Store Lifespan', () => {
       setup() {
         const store = useStore()
         watch(() => store.n, inComponentWatch)
-        store.n++
+        onMounted(() => {
+          store.n++
+        })
       },
     })
 
@@ -49,6 +51,7 @@ describe('Store Lifespan', () => {
     }
 
     let wrapper = mount(Component, options)
+    await nextTick()
 
     await wrapper.unmount()
 
@@ -60,6 +63,7 @@ describe('Store Lifespan', () => {
     expect(inComponentWatch).toHaveBeenCalledTimes(1)
 
     wrapper = mount(Component, options)
+    await nextTick()
     await wrapper.unmount()
 
     expect(inComponentWatch).toHaveBeenCalledTimes(2)