From 692528cd1246ec7283c8d95a7f3aa23a4c6cc40a Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Wed, 21 Jan 2026 21:24:37 +0100 Subject: [PATCH] refactor: remove any types from systemStatsStore.test.ts - Import SystemStats type from apiSchema - Replace null as any with proper SystemStats type - Replace Promise with Promise - Replace partial system object cast with SystemStats['system'] - Add necessary cast for empty object in test --- src/stores/systemStatsStore.test.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/stores/systemStatsStore.test.ts b/src/stores/systemStatsStore.test.ts index 49653c780..28d4f20c9 100644 --- a/src/stores/systemStatsStore.test.ts +++ b/src/stores/systemStatsStore.test.ts @@ -1,6 +1,7 @@ import { createPinia, setActivePinia } from 'pinia' import { beforeEach, describe, expect, it, vi } from 'vitest' +import type { SystemStats } from '@/schemas/apiSchema' import { api } from '@/scripts/api' import { useSystemStatsStore } from '@/stores/systemStatsStore' import { isElectron } from '@/utils/envUtil' @@ -24,7 +25,9 @@ describe('useSystemStatsStore', () => { beforeEach(() => { // Mock API to prevent automatic fetch on store creation - vi.mocked(api.getSystemStats).mockResolvedValue(null as any) + vi.mocked(api.getSystemStats).mockResolvedValue( + null as unknown as SystemStats + ) setActivePinia(createPinia()) store = useSystemStatsStore() vi.clearAllMocks() @@ -89,8 +92,8 @@ describe('useSystemStatsStore', () => { }) it('should set loading state correctly', async () => { - let resolvePromise: (value: any) => void = () => {} - const promise = new Promise((resolve) => { + let resolvePromise: (value: SystemStats) => void = () => {} + const promise = new Promise((resolve) => { resolvePromise = resolve }) vi.mocked(api.getSystemStats).mockReturnValue(promise) @@ -98,7 +101,7 @@ describe('useSystemStatsStore', () => { const fetchPromise = store.refetchSystemStats() expect(store.isLoading).toBe(true) - resolvePromise({}) + resolvePromise({} as unknown as SystemStats) await fetchPromise expect(store.isLoading).toBe(false) @@ -152,7 +155,7 @@ describe('useSystemStatsStore', () => { argv: [], ram_total: 16000000000, ram_free: 8000000000 - } as any, + } as unknown as SystemStats['system'], devices: [] }