diff --git a/core/src/browser/core.test.ts b/core/src/browser/core.test.ts index 1bb80d9eb..6197da023 100644 --- a/core/src/browser/core.test.ts +++ b/core/src/browser/core.test.ts @@ -1,3 +1,6 @@ +/** + * @jest-environment jsdom + */ import { openExternalUrl } from './core' import { joinPath } from './core' import { openFileExplorer } from './core' @@ -51,20 +54,6 @@ describe('test core apis', () => { expect(globalThis.core.api.getJanDataFolderPath).toHaveBeenCalled() expect(result).toBe('/path/to/jan/data') }) - - it('should execute function on main process', async () => { - const extension = 'testExtension' - const method = 'testMethod' - const args = ['arg1', 'arg2'] - globalThis.core = { - api: { - invokeExtensionFunc: jest.fn().mockResolvedValue('result'), - }, - } - const result = await executeOnMain(extension, method, ...args) - expect(globalThis.core.api.invokeExtensionFunc).toHaveBeenCalledWith(extension, method, ...args) - expect(result).toBe('result') - }) }) describe('dirName - just a pass thru api', () => { diff --git a/web/hooks/useLoadTheme.test.ts b/web/hooks/useLoadTheme.test.ts index e17a67ed8..1a3965bbb 100644 --- a/web/hooks/useLoadTheme.test.ts +++ b/web/hooks/useLoadTheme.test.ts @@ -40,9 +40,12 @@ describe('useLoadTheme', () => { } it('should load theme and set variables', async () => { + const readTheme = jest.fn().mockResolvedValue("{}") + global.window.core = { api: { getThemes: () => ['joi-light', 'joi-dark'], + readTheme, }, } // Mock Jotai hooks @@ -93,10 +96,7 @@ describe('useLoadTheme', () => { }) // Assertions - expect(fs.readFileSync).toHaveBeenLastCalledWith( - `file://themes/joi-light/theme.json`, - 'utf-8' - ) + expect(readTheme).toHaveBeenLastCalledWith({ theme: 'joi-light' }) }) it('should set default theme if no selected theme', async () => { diff --git a/web/hooks/useLoadTheme.ts b/web/hooks/useLoadTheme.ts index 61cf62d1b..f2fbbf83e 100644 --- a/web/hooks/useLoadTheme.ts +++ b/web/hooks/useLoadTheme.ts @@ -37,6 +37,7 @@ export const useLoadTheme = () => { ) const applyTheme = (theme: Theme) => { + if (!theme.variables) return const variables = cssVars(theme.variables) const headTag = document.getElementsByTagName('head')[0] const styleTag = document.createElement('style')