Files
2026-07-13 13:20:22 +08:00

40 lines
988 B
TypeScript

/**
* Vitest Test Setup
* Global configuration for extension system tests
*/
// Register NodePlatformServices so modules that call getPlatformServices() work in tests.
import { registerPlatformServices } from '@/common/platform';
import { NodePlatformServices } from '@/common/platform/NodePlatformServices';
registerPlatformServices(new NodePlatformServices());
// Make this a module
// Extend global types for testing
declare global {
// eslint-disable-next-line no-var
var electronAPI: any;
}
const noop = () => Promise.resolve();
// Mock Electron APIs for testing
const windowControlsMock = {
minimize: noop,
maximize: noop,
unmaximize: noop,
close: noop,
isMaximized: () => Promise.resolve(false),
onMaximizedChange: (): (() => void) => () => void 0,
};
(global as any).electronAPI = {
emit: noop,
on: () => {},
windowControls: windowControlsMock,
};
if (typeof window !== 'undefined') {
(window as any).electronAPI = (global as any).electronAPI;
}