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() {
setup() {
const store = useStore()
watch(() => store.n, inComponentWatch)
- store.n++
+ onMounted(() => {
+ store.n++
+ })
},
})
}
let wrapper = mount(Component, options)
+ await nextTick()
await wrapper.unmount()
expect(inComponentWatch).toHaveBeenCalledTimes(1)
wrapper = mount(Component, options)
+ await nextTick()
await wrapper.unmount()
expect(inComponentWatch).toHaveBeenCalledTimes(2)