feat: replace polling with Tauri events and add unit tests
- Backend now emits playback:state events every 250ms when state changes - PlayerStore uses listen() instead of setInterval for real-time updates - Added Vitest testing framework with mocked Tauri APIs - Added 53 unit tests for playerStore and queueStore
This commit is contained in:
1 parent
6dfcc8adaa
commit
71156e9d0a
8 files changed
+1872
-48
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Vitest Setup
|
||||
*
|
||||
* Mocks Tauri APIs for unit testing frontend stores.
|
||||
*/
|
||||
|
||||
import { vi } from 'vitest';
|
||||
|
||||
// Mock @tauri-apps/api/core
|
||||
vi.mock('@tauri-apps/api/core', () => ({
|
||||
invoke: vi.fn()
|
||||
}));
|
||||
|
||||
// Mock @tauri-apps/api/event
|
||||
vi.mock('@tauri-apps/api/event', () => ({
|
||||
listen: vi.fn(() => Promise.resolve(() => {})),
|
||||
emit: vi.fn()
|
||||
}));
|
||||
|
||||
// Mock localStorage
|
||||
const localStorageMock = {
|
||||
getItem: vi.fn(),
|
||||
setItem: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
clear: vi.fn(),
|
||||
length: 0,
|
||||
key: vi.fn()
|
||||
};
|
||||
Object.defineProperty(global, 'localStorage', { value: localStorageMock });
|
||||
Reference in new issue
Block a user