test: update test case
This commit is contained in:
parent
339917c131
commit
304ae4fbc8
@ -4,6 +4,11 @@ import { fs, joinPath } from '@janhq/core'
|
|||||||
import { useAtom, useAtomValue, useSetAtom } from 'jotai'
|
import { useAtom, useAtomValue, useSetAtom } from 'jotai'
|
||||||
|
|
||||||
import { useLoadTheme } from './useLoadTheme'
|
import { useLoadTheme } from './useLoadTheme'
|
||||||
|
import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom'
|
||||||
|
import {
|
||||||
|
selectedThemeIdAtom,
|
||||||
|
themeDataAtom,
|
||||||
|
} from '@/helpers/atoms/Setting.atom'
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
jest.mock('next-themes')
|
jest.mock('next-themes')
|
||||||
@ -36,10 +41,25 @@ describe('useLoadTheme', () => {
|
|||||||
|
|
||||||
it('should load theme and set variables', async () => {
|
it('should load theme and set variables', async () => {
|
||||||
// Mock Jotai hooks
|
// Mock Jotai hooks
|
||||||
;(useAtomValue as jest.Mock).mockReturnValue(mockJanDataFolderPath)
|
;(useAtomValue as jest.Mock).mockImplementation((atom) => {
|
||||||
|
switch (atom) {
|
||||||
|
case janDataFolderPathAtom:
|
||||||
|
return mockJanDataFolderPath
|
||||||
|
default:
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
;(useSetAtom as jest.Mock).mockReturnValue(jest.fn())
|
;(useSetAtom as jest.Mock).mockReturnValue(jest.fn())
|
||||||
;(useAtom as jest.Mock).mockReturnValue([mockSelectedThemeId, jest.fn()])
|
;(useAtom as jest.Mock).mockImplementation((atom) => {
|
||||||
;(useAtom as jest.Mock).mockReturnValue([mockThemeData, jest.fn()])
|
switch (atom) {
|
||||||
|
case selectedThemeIdAtom:
|
||||||
|
return [mockSelectedThemeId, jest.fn()]
|
||||||
|
case themeDataAtom:
|
||||||
|
return [mockThemeData, jest.fn()]
|
||||||
|
default:
|
||||||
|
return [undefined, jest.fn()]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Mock fs and joinPath
|
// Mock fs and joinPath
|
||||||
;(fs.readdirSync as jest.Mock).mockResolvedValue(['joi-light', 'joi-dark'])
|
;(fs.readdirSync as jest.Mock).mockResolvedValue(['joi-light', 'joi-dark'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user