From 09761f21bc7f354f57be6caf9e04dd99361058e8 Mon Sep 17 00:00:00 2001 From: suyao Date: Tue, 13 May 2025 00:42:36 +0800 Subject: [PATCH] fix: add mocks for minapps configuration and window.api in export tests --- .../src/utils/__tests__/export.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/renderer/src/utils/__tests__/export.test.ts b/src/renderer/src/utils/__tests__/export.test.ts index 5d308f5a5..f252d0313 100644 --- a/src/renderer/src/utils/__tests__/export.test.ts +++ b/src/renderer/src/utils/__tests__/export.test.ts @@ -5,6 +5,29 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' // --- Mocks Setup --- +// Add this before the test suites +vi.mock('@renderer/config/minapps', () => { + return { + ORIGIN_DEFAULT_MIN_APPS: [], + DEFAULT_MIN_APPS: [], + loadCustomMiniApp: async () => [], + updateDefaultMinApps: vi.fn() + } +}) + +// Mock window.api +beforeEach(() => { + Object.defineProperty(window, 'api', { + value: { + file: { + read: vi.fn().mockResolvedValue('[]'), + writeWithId: vi.fn() + } + }, + configurable: true + }) +}) + // Mock i18n at the top level using vi.mock vi.mock('@renderer/i18n', () => ({ default: {