From 9b2c8a47a4fb65f14a89d6bdd5fd2a6f25b0cbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Wed, 8 Apr 2026 07:09:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Login=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=B5=8B=E8=AF=95=E7=9A=84=20Pinia=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/components/Login.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/novalon-manage-web/src/test/components/Login.test.ts b/novalon-manage-web/src/test/components/Login.test.ts index c3bb75d..20904bf 100644 --- a/novalon-manage-web/src/test/components/Login.test.ts +++ b/novalon-manage-web/src/test/components/Login.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest' import { mount } from '@vue/test-utils' import { createRouter, createMemoryHistory } from 'vue-router' +import { createPinia, setActivePinia } from 'pinia' import Login from '@/views/system/Login.vue' vi.mock('vue-router') @@ -20,8 +21,12 @@ vi.mock('@/utils/request', () => ({ describe('Login Component', () => { let router: any let wrapper: any + let pinia: any beforeEach(() => { + pinia = createPinia() + setActivePinia(pinia) + router = createRouter({ history: createMemoryHistory(), routes: [ @@ -44,7 +49,7 @@ describe('Login Component', () => { it('should render login form', () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -62,7 +67,7 @@ describe('Login Component', () => { it('should initialize with empty form state', () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -80,7 +85,7 @@ describe('Login Component', () => { it('should initialize loading as false', () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -99,7 +104,7 @@ describe('Login Component', () => { it('should update username when input changes', async () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -119,7 +124,7 @@ describe('Login Component', () => { it('should update password when input changes', async () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -141,7 +146,7 @@ describe('Login Component', () => { it('should have onFinish method', () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true, @@ -162,7 +167,7 @@ describe('Login Component', () => { wrapper = mount(Login, { global: { - plugins: [router], + plugins: [router, pinia], stubs: { 'el-card': true, 'el-form': true,