test: api mock for test failing

This commit is contained in:
Jin Yi
2025-09-12 19:51:29 +09:00
parent f37d50545d
commit 06ca56c05e
3 changed files with 30 additions and 0 deletions

View File

@@ -17,6 +17,16 @@ vi.mock('@/utils/formatUtil', () => ({
normalizeI18nKey: vi.fn()
}))
// Mock the api module
vi.mock('@/scripts/api', () => ({
api: {
fileURL: (path: string) => `/fileURL${path}`,
apiURL: (path: string) => `/apiURL${path}`,
addEventListener: vi.fn(),
removeEventListener: vi.fn()
}
}))
describe('SettingItem', () => {
const mountComponent = (props: any, options = {}): any => {
return mount(SettingItem, {

View File

@@ -10,6 +10,16 @@ import * as markdownRendererUtil from '@/utils/markdownRendererUtil'
import NodePreview from './NodePreview.vue'
// Mock the api module
vi.mock('@/scripts/api', () => ({
api: {
fileURL: (path: string) => `/fileURL${path}`,
apiURL: (path: string) => `/apiURL${path}`,
addEventListener: vi.fn(),
removeEventListener: vi.fn()
}
}))
describe('NodePreview', () => {
let i18n: ReturnType<typeof createI18n>
let pinia: ReturnType<typeof createPinia>

View File

@@ -9,6 +9,16 @@ import type { ResultItemImpl } from '@/stores/queueStore'
import ResultGallery from './ResultGallery.vue'
// Mock the api module
vi.mock('@/scripts/api', () => ({
api: {
fileURL: (path: string) => `/fileURL${path}`,
apiURL: (path: string) => `/apiURL${path}`,
addEventListener: vi.fn(),
removeEventListener: vi.fn()
}
}))
type MockResultItem = Partial<ResultItemImpl> & {
filename: string
subfolder: string