Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: test

Louisdcb46174ff03
diff --git a/web-app/src/hooks/__tests__/useAppUpdater.test.ts b/web-app/src/hooks/__tests__/useAppUpdater.test.ts
index 250c37fed..2c736f0f3 100644
--- a/web-app/src/hooks/__tests__/useAppUpdater.test.ts
+++ b/web-app/src/hooks/__tests__/useAppUpdater.test.ts
@@ -48,6 +48,12 @@ Object.defineProperty(window, 'core', {
writable: true,
})
+// Mock global AUTO_UPDATER_DISABLED
+Object.defineProperty(global, 'AUTO_UPDATER_DISABLED', {
+ value: false,
+ writable: true,
+})
+
import { isDev } from '@/lib/utils'
import { check } from '@tauri-apps/plugin-updater'
import { events } from '@janhq/core'
@@ -251,11 +257,14 @@ describe('useAppUpdater', () => {
downloadAndInstall: mockDownloadAndInstall,
}
+ // Mock check to return the update
+ mockCheck.mockResolvedValue(mockUpdate)
+
const { result } = renderHook(() => useAppUpdater())
- // Set update info first
- act(() => {
- result.current.updateState.updateInfo = mockUpdate
+ // Set update info first by calling checkForUpdate
+ await act(async () => {
+ await result.current.checkForUpdate()
})
// Mock the download and install process
@@ -296,11 +305,14 @@ describe('useAppUpdater', () => {
downloadAndInstall: mockDownloadAndInstall,
}
+ // Mock check to return the update
+ mockCheck.mockResolvedValue(mockUpdate)
+
const { result } = renderHook(() => useAppUpdater())
- // Set update info first
- act(() => {
- result.current.updateState.updateInfo = mockUpdate
+ // Set update info first by calling checkForUpdate
+ await act(async () => {
+ await result.current.checkForUpdate()
})
mockDownloadAndInstall.mockRejectedValue(new Error('Download failed'))
@@ -338,11 +350,14 @@ describe('useAppUpdater', () => {
downloadAndInstall: mockDownloadAndInstall,
}
+ // Mock check to return the update
+ mockCheck.mockResolvedValue(mockUpdate)
+
const { result } = renderHook(() => useAppUpdater())
- // Set update info first
- act(() => {
- result.current.updateState.updateInfo = mockUpdate
+ // Set update info first by calling checkForUpdate
+ await act(async () => {
+ await result.current.checkForUpdate()
})
mockDownloadAndInstall.mockImplementation(async (progressCallback) => {