mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-28 04:49:49 -07:00
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { createStatsOverlayVisibilityChangeHandler } from './stats-overlay-visibility';
|
|
|
|
test('stats overlay visibility handler makes overlay mouse-passive before opening stats', () => {
|
|
const calls: string[] = [];
|
|
const handler = createStatsOverlayVisibilityChangeHandler({
|
|
setStatsOverlayVisibleState: (visible) => calls.push(`state:${visible}`),
|
|
resetVisibleOverlayInteraction: () => calls.push('reset-interaction'),
|
|
getMainWindow: () =>
|
|
({
|
|
isDestroyed: () => false,
|
|
isVisible: () => true,
|
|
setIgnoreMouseEvents: (ignore: boolean, options?: { forward?: boolean }) => {
|
|
calls.push(`mouse-ignore:${ignore}:${options?.forward === true ? 'forward' : 'plain'}`);
|
|
},
|
|
}) as never,
|
|
updateVisibleOverlayVisibility: () => calls.push('update-visible'),
|
|
});
|
|
|
|
handler(true);
|
|
|
|
assert.deepEqual(calls, [
|
|
'state:true',
|
|
'reset-interaction',
|
|
'mouse-ignore:true:forward',
|
|
'update-visible',
|
|
]);
|
|
});
|
|
|
|
test('stats overlay visibility handler restores overlay then leaves mpv mouse-responsive after close', () => {
|
|
const calls: string[] = [];
|
|
const handler = createStatsOverlayVisibilityChangeHandler({
|
|
setStatsOverlayVisibleState: (visible) => calls.push(`state:${visible}`),
|
|
resetVisibleOverlayInteraction: () => calls.push('reset-interaction'),
|
|
getMainWindow: () =>
|
|
({
|
|
isDestroyed: () => false,
|
|
isVisible: () => true,
|
|
setIgnoreMouseEvents: (ignore: boolean, options?: { forward?: boolean }) => {
|
|
calls.push(`mouse-ignore:${ignore}:${options?.forward === true ? 'forward' : 'plain'}`);
|
|
},
|
|
}) as never,
|
|
updateVisibleOverlayVisibility: () => calls.push('update-visible'),
|
|
});
|
|
|
|
handler(false);
|
|
|
|
assert.deepEqual(calls, [
|
|
'state:false',
|
|
'reset-interaction',
|
|
'update-visible',
|
|
'mouse-ignore:true:forward',
|
|
]);
|
|
});
|