From: Eduardo San Martin Morote Date: Thu, 8 Jul 2021 08:50:34 +0000 (+0200) Subject: test: fix lifespan test X-Git-Tag: v2.0.0-rc.0~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc3add404c2baad551ec9c3afa4f96742fda4308;p=thirdparty%2Fvuejs%2Fpinia.git test: fix lifespan test --- diff --git a/__tests__/lifespan.spec.ts b/__tests__/lifespan.spec.ts index 1ab83bd5..1b589a77 100644 --- a/__tests__/lifespan.spec.ts +++ b/__tests__/lifespan.spec.ts @@ -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)