From 9d052656e7c5e772f28eabb5e3a7e443604249e7 Mon Sep 17 00:00:00 2001 From: Shyam-Chen Date: Mon, 13 May 2024 10:44:50 +0800 Subject: [PATCH] 1,460th Commit --- .../crud-operations/__tests__/+page.spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/routes/(backstage)/(playground)/crud-operations/__tests__/+page.spec.ts b/app/src/routes/(backstage)/(playground)/crud-operations/__tests__/+page.spec.ts index eec4ba89..5fd7d655 100644 --- a/app/src/routes/(backstage)/(playground)/crud-operations/__tests__/+page.spec.ts +++ b/app/src/routes/(backstage)/(playground)/crud-operations/__tests__/+page.spec.ts @@ -1,5 +1,6 @@ import type { VueWrapper } from '@vue/test-utils'; import { mount, flushPromises } from '@vue/test-utils'; +import * as vueRouter from 'vue-router'; import * as xui from '@x/ui'; import todos from 'mock/todos/response'; @@ -13,6 +14,7 @@ let wrapper: VueWrapper; afterEach(() => { wrapper.unmount(); + vi.clearAllMocks(); }); test('initial', async () => { @@ -22,6 +24,15 @@ test('initial', async () => { } }); + vi.mock('vue-router', async (importOriginal) => { + const actual = await importOriginal(); + + return { + ...actual, + onBeforeRouteLeave: vi.fn(), + }; + }); + wrapper = mount(Page, { global: { plugins: [router, localer] } }); await flushPromises();