From d5aa33dd19eabac952c513665237054f685713fc Mon Sep 17 00:00:00 2001 From: paisley <8197966+su8su@users.noreply.github.com> Date: Mon, 9 Mar 2026 11:26:42 +0800 Subject: [PATCH] add test --- tests/unit/stores.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/unit/stores.test.ts b/tests/unit/stores.test.ts index 662c365..42fe4bf 100644 --- a/tests/unit/stores.test.ts +++ b/tests/unit/stores.test.ts @@ -1,7 +1,7 @@ /** * Zustand Stores Tests */ -import { describe, it, expect, beforeEach } from 'vitest'; +import { describe, it, expect, beforeEach, vi } from 'vitest'; import { useSettingsStore } from '@/stores/settings'; import { useGatewayStore } from '@/stores/gateway'; @@ -72,4 +72,14 @@ describe('Gateway Store', () => { expect(state.status.state).toBe('running'); expect(state.status.pid).toBe(12345); }); + + it('should proxy gateway rpc through ipc', async () => { + const invoke = vi.mocked(window.electron.ipcRenderer.invoke); + invoke.mockResolvedValueOnce({ success: true, result: { ok: true } }); + + const result = await useGatewayStore.getState().rpc<{ ok: boolean }>('chat.history', { limit: 10 }, 5000); + + expect(result.ok).toBe(true); + expect(invoke).toHaveBeenCalledWith('gateway:rpc', 'chat.history', { limit: 10 }, 5000); + }); });