From f3326bc16198ee76fa2ece9417154feea01721f7 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 7 Apr 2025 14:11:25 +0700 Subject: [PATCH] chore: fix tests --- core/src/browser/index.test.ts | 5 ----- web/hooks/useLoadTheme.test.ts | 17 +---------------- web/screens/Thread/index.test.tsx | 4 ++++ 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/core/src/browser/index.test.ts b/core/src/browser/index.test.ts index c8cabbb0b..fcdb635ff 100644 --- a/core/src/browser/index.test.ts +++ b/core/src/browser/index.test.ts @@ -3,7 +3,6 @@ import * as Events from './events' import * as FileSystem from './fs' import * as Extension from './extension' import * as Extensions from './extensions' -import * as Tools from './tools' import * as Models from './models' describe('Module Tests', () => { @@ -27,10 +26,6 @@ describe('Module Tests', () => { expect(Extensions).toBeDefined() }) - it('should export all base tools', () => { - expect(Tools).toBeDefined() - }) - it('should export all base tools', () => { expect(Models).toBeDefined() }) diff --git a/web/hooks/useLoadTheme.test.ts b/web/hooks/useLoadTheme.test.ts index 1a3965bbb..c378fb2e6 100644 --- a/web/hooks/useLoadTheme.test.ts +++ b/web/hooks/useLoadTheme.test.ts @@ -4,7 +4,6 @@ import { fs, joinPath } from '@janhq/core' import { useAtom, useAtomValue, useSetAtom } from 'jotai' import { useLoadTheme } from './useLoadTheme' -import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom' import { selectedThemeIdAtom, themeDataAtom, @@ -27,8 +26,6 @@ describe('useLoadTheme', () => { jest.clearAllMocks() }) - const mockJanDataFolderPath = '/mock/path' - const mockThemesPath = '/mock/path/themes' const mockSelectedThemeId = 'joi-light' const mockThemeData = { id: 'joi-light', @@ -51,8 +48,6 @@ describe('useLoadTheme', () => { // Mock Jotai hooks ;(useAtomValue as jest.Mock).mockImplementation((atom) => { switch (atom) { - case janDataFolderPathAtom: - return mockJanDataFolderPath default: return undefined } @@ -80,15 +75,6 @@ describe('useLoadTheme', () => { const mockSetTheme = jest.fn() ;(useTheme as jest.Mock).mockReturnValue({ setTheme: mockSetTheme }) - // Mock window.electronAPI - Object.defineProperty(window, 'electronAPI', { - value: { - setNativeThemeLight: jest.fn(), - setNativeThemeDark: jest.fn(), - }, - writable: true, - }) - const { result } = renderHook(() => useLoadTheme()) await act(async () => { @@ -96,12 +82,11 @@ describe('useLoadTheme', () => { }) // Assertions - expect(readTheme).toHaveBeenLastCalledWith({ theme: 'joi-light' }) + expect(readTheme).toHaveBeenLastCalledWith({ themeName: 'joi-light' }) }) it('should set default theme if no selected theme', async () => { // Mock Jotai hooks with empty selected theme - ;(useAtomValue as jest.Mock).mockReturnValue(mockJanDataFolderPath) ;(useSetAtom as jest.Mock).mockReturnValue(jest.fn()) ;(useAtom as jest.Mock).mockReturnValue(['', jest.fn()]) ;(useAtom as jest.Mock).mockReturnValue([{}, jest.fn()]) diff --git a/web/screens/Thread/index.test.tsx b/web/screens/Thread/index.test.tsx index 6b4ecdc93..8f2b19e91 100644 --- a/web/screens/Thread/index.test.tsx +++ b/web/screens/Thread/index.test.tsx @@ -1,3 +1,7 @@ +/** + * @jest-environment jsdom + */ +import 'openai/shims/node' import React from 'react' import { act, render, screen, waitFor } from '@testing-library/react' import ThreadScreen from './index'