Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion electron/src/services/ipc/update-handlers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type Mock,
type Mocked,
} from 'vitest';
import { ipcMain } from 'electron';
import { app, ipcMain } from 'electron';
import { setupUpdateHandlers } from './update-handlers.js';
import { UpdateManager } from '../updater/update-manager.js';
import {
Expand Down Expand Up @@ -100,6 +100,10 @@ describe('Update IPC Handlers', () => {
'update:get-status',
expect.any(Function),
);
expect(ipcMain.handle).toHaveBeenCalledWith(
'update:get-app-version',
expect.any(Function),
);
});

it('should initialize UpdateManager instance', () => {
Expand Down Expand Up @@ -311,4 +315,27 @@ describe('Update IPC Handlers', () => {
});
});
});

describe('update:get-app-version handler', () => {
it('should return app version successfully', async () => {
setupUpdateHandlers();
const handler = ipcHandlers.get('update:get-app-version')!;

const result = await handler();

expect(result).toEqual({ success: true, version: '1.0.0' });
});

it('should handle get version error', async () => {
setupUpdateHandlers();
const handler = ipcHandlers.get('update:get-app-version')!;
(app.getVersion as Mock).mockImplementation(() => {
throw new Error('Version error');
});

const result = await handler();

expect(result).toEqual({ success: false, error: 'Version error' });
});
});
});
Loading
Loading