From d96f369b73467d4373b8dfae717d05b0e10a9240 Mon Sep 17 00:00:00 2001 From: Kacper Date: Fri, 16 Jan 2026 20:38:29 +0100 Subject: [PATCH] test: mock Unix platform for SIGTERM behavior in ClaudeUsageService tests Added a mock for the Unix platform in the SIGTERM test case to ensure proper behavior during testing on non-Windows systems. This change enhances the reliability of the tests by simulating the expected environment for process termination. --- .../server/tests/unit/services/claude-usage-service.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/server/tests/unit/services/claude-usage-service.test.ts b/apps/server/tests/unit/services/claude-usage-service.test.ts index 4b3f3c94..65699ca6 100644 --- a/apps/server/tests/unit/services/claude-usage-service.test.ts +++ b/apps/server/tests/unit/services/claude-usage-service.test.ts @@ -681,7 +681,9 @@ Resets in 2h it('should send SIGTERM after ESC if process does not exit', async () => { vi.useFakeTimers(); - const windowsService = new ClaudeUsageService(); + // Mock Unix platform to test SIGTERM behavior (Windows calls kill() without signal) + vi.mocked(os.platform).mockReturnValue('darwin'); + const ptyService = new ClaudeUsageService(); let dataCallback: Function | undefined; @@ -696,7 +698,7 @@ Resets in 2h }; vi.mocked(pty.spawn).mockReturnValue(mockPty as any); - windowsService.fetchUsageData(); + ptyService.fetchUsageData(); // Simulate seeing usage data dataCallback!('Current session\n65% left');