mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 16:19:24 -07:00
test: mock win32 in overlay runtime init test
This commit is contained in:
@@ -2,6 +2,23 @@ import assert from 'node:assert/strict';
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { initializeOverlayAnkiIntegration, initializeOverlayRuntime } from './overlay-runtime-init';
|
import { initializeOverlayAnkiIntegration, initializeOverlayRuntime } from './overlay-runtime-init';
|
||||||
|
|
||||||
|
function withPlatform(platform: NodeJS.Platform, run: () => void): void {
|
||||||
|
const originalPlatform = process.platform;
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: platform,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
run();
|
||||||
|
} finally {
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: originalPlatform,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test('initializeOverlayRuntime skips Anki integration when ankiConnect.enabled is false', () => {
|
test('initializeOverlayRuntime skips Anki integration when ankiConnect.enabled is false', () => {
|
||||||
let createdIntegrations = 0;
|
let createdIntegrations = 0;
|
||||||
let startedIntegrations = 0;
|
let startedIntegrations = 0;
|
||||||
@@ -548,6 +565,7 @@ test('initializeOverlayRuntime hides overlay windows when tracker loses the targ
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('initializeOverlayRuntime preserves visible overlay on Windows tracker loss when target is not minimized', () => {
|
test('initializeOverlayRuntime preserves visible overlay on Windows tracker loss when target is not minimized', () => {
|
||||||
|
withPlatform('win32', () => {
|
||||||
const calls: string[] = [];
|
const calls: string[] = [];
|
||||||
const tracker = {
|
const tracker = {
|
||||||
onGeometryChange: null as ((...args: unknown[]) => void) | null,
|
onGeometryChange: null as ((...args: unknown[]) => void) | null,
|
||||||
@@ -602,6 +620,7 @@ test('initializeOverlayRuntime preserves visible overlay on Windows tracker loss
|
|||||||
|
|
||||||
assert.deepEqual(calls, ['sync-shortcuts']);
|
assert.deepEqual(calls, ['sync-shortcuts']);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('initializeOverlayRuntime restores overlay bounds and visibility when tracker finds the target window again', () => {
|
test('initializeOverlayRuntime restores overlay bounds and visibility when tracker finds the target window again', () => {
|
||||||
const bounds: Array<{ x: number; y: number; width: number; height: number }> = [];
|
const bounds: Array<{ x: number; y: number; width: number; height: number }> = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user