Files
SubMiner/src/main/runtime/current-media-tokenization-gate.test.ts
sudacode e0f82d28f0 Improve startup dictionary sync UX and default playback keybindings
- Add default `f` fullscreen overlay binding and switch default AniSkip skip key to `Tab`
- Make character-dictionary auto-sync non-blocking at startup with tokenization gating for Yomitan mutations
- Add ordered startup OSD progress (checking/generating/updating/importing), refresh current subtitle on sync completion, and extend regression tests
2026-03-09 00:50:32 -07:00

43 lines
1.3 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createCurrentMediaTokenizationGate } from './current-media-tokenization-gate';
test('current media tokenization gate waits until current path is marked ready', async () => {
const gate = createCurrentMediaTokenizationGate();
gate.updateCurrentMediaPath('/tmp/video-1.mkv');
let resolved = false;
const waitPromise = gate.waitUntilReady('/tmp/video-1.mkv').then(() => {
resolved = true;
});
await Promise.resolve();
assert.equal(resolved, false);
gate.markReady('/tmp/video-1.mkv');
await waitPromise;
assert.equal(resolved, true);
});
test('current media tokenization gate resolves old waiters when media changes', async () => {
const gate = createCurrentMediaTokenizationGate();
gate.updateCurrentMediaPath('/tmp/video-1.mkv');
let resolved = false;
const waitPromise = gate.waitUntilReady('/tmp/video-1.mkv').then(() => {
resolved = true;
});
gate.updateCurrentMediaPath('/tmp/video-2.mkv');
await waitPromise;
assert.equal(resolved, true);
});
test('current media tokenization gate returns immediately for ready media', async () => {
const gate = createCurrentMediaTokenizationGate();
gate.updateCurrentMediaPath('/tmp/video-1.mkv');
gate.markReady('/tmp/video-1.mkv');
await gate.waitUntilReady('/tmp/video-1.mkv');
});