develop #2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user