fix frontend test debt

This commit is contained in:
2026-03-18 16:03:54 +08:00
parent 5ead63c160
commit 9cba09d731
3 changed files with 24 additions and 12 deletions
@@ -1,8 +1,19 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { setActivePinia, createPinia } from 'pinia'
import { mount } from '@vue/test-utils'
import { createRouter, createMemoryHistory } from 'vue-router'
import MainLayout from '../MainLayout.vue'
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false, media: query, onchange: null,
addListener: () => {}, removeListener: () => {},
addEventListener: () => {}, removeEventListener: () => {},
dispatchEvent: () => false,
}),
})
function createTestRouter() {
return createRouter({
history: createMemoryHistory(),
@@ -17,6 +28,7 @@ function createTestRouter() {
describe('MainLayout', () => {
beforeEach(() => {
setActivePinia(createPinia())
localStorage.clear()
})