mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 06:12:06 -07:00
test: add behavioral assertions to composer tests
Upgrade 8 composer test files from shape-only typeof checks to behavioral assertions that invoke returned handlers and verify injected dependencies are actually called, following the mpv-runtime-composer pattern.
This commit is contained in:
@@ -3,15 +3,20 @@ import test from 'node:test';
|
||||
import { composeOverlayVisibilityRuntime } from './overlay-visibility-runtime-composer';
|
||||
|
||||
test('composeOverlayVisibilityRuntime returns overlay visibility handlers', () => {
|
||||
const calls: string[] = [];
|
||||
const composed = composeOverlayVisibilityRuntime({
|
||||
overlayVisibilityRuntime: {
|
||||
updateVisibleOverlayVisibility: () => {},
|
||||
updateVisibleOverlayVisibility: () => {
|
||||
calls.push('updateVisibleOverlayVisibility');
|
||||
},
|
||||
},
|
||||
restorePreviousSecondarySubVisibilityMainDeps: {
|
||||
getMpvClient: () => null,
|
||||
},
|
||||
broadcastRuntimeOptionsChangedMainDeps: {
|
||||
broadcastRuntimeOptionsChangedRuntime: () => {},
|
||||
broadcastRuntimeOptionsChangedRuntime: () => {
|
||||
calls.push('broadcastRuntimeOptionsChangedRuntime');
|
||||
},
|
||||
getRuntimeOptionsState: () => [],
|
||||
broadcastToOverlayWindows: () => {},
|
||||
},
|
||||
@@ -24,7 +29,9 @@ test('composeOverlayVisibilityRuntime returns overlay visibility handlers', () =
|
||||
setCurrentEnabled: () => {},
|
||||
},
|
||||
openRuntimeOptionsPaletteMainDeps: {
|
||||
openRuntimeOptionsPaletteRuntime: () => {},
|
||||
openRuntimeOptionsPaletteRuntime: () => {
|
||||
calls.push('openRuntimeOptionsPaletteRuntime');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -34,4 +41,16 @@ test('composeOverlayVisibilityRuntime returns overlay visibility handlers', () =
|
||||
assert.equal(typeof composed.sendToActiveOverlayWindow, 'function');
|
||||
assert.equal(typeof composed.setOverlayDebugVisualizationEnabled, 'function');
|
||||
assert.equal(typeof composed.openRuntimeOptionsPalette, 'function');
|
||||
|
||||
// updateVisibleOverlayVisibility passes through to the injected runtime dep
|
||||
composed.updateVisibleOverlayVisibility();
|
||||
assert.deepEqual(calls, ['updateVisibleOverlayVisibility']);
|
||||
|
||||
// openRuntimeOptionsPalette forwards to the injected runtime dep
|
||||
composed.openRuntimeOptionsPalette();
|
||||
assert.deepEqual(calls, ['updateVisibleOverlayVisibility', 'openRuntimeOptionsPaletteRuntime']);
|
||||
|
||||
// broadcastRuntimeOptionsChanged forwards to the injected runtime dep
|
||||
composed.broadcastRuntimeOptionsChanged();
|
||||
assert.ok(calls.includes('broadcastRuntimeOptionsChangedRuntime'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user