mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-20 17:01:24 -07:00
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { showMpvOsdRuntime } from './mpv';
|
|
|
|
test('showMpvOsdRuntime sends show-text when connected', () => {
|
|
const commands: (string | number)[][] = [];
|
|
const shown = showMpvOsdRuntime(
|
|
{
|
|
connected: true,
|
|
send: ({ command }) => {
|
|
commands.push(command);
|
|
},
|
|
},
|
|
'hello',
|
|
);
|
|
assert.equal(shown, true);
|
|
assert.deepEqual(commands, [['show-text', 'hello', '3000']]);
|
|
});
|
|
|
|
test('showMpvOsdRuntime enables property expansion for placeholder-based messages', () => {
|
|
const commands: (string | number)[][] = [];
|
|
const shown = showMpvOsdRuntime(
|
|
{
|
|
connected: true,
|
|
send: ({ command }) => {
|
|
commands.push(command);
|
|
},
|
|
},
|
|
'Subtitle delay: ${sub-delay}',
|
|
);
|
|
assert.equal(shown, true);
|
|
assert.deepEqual(commands, [
|
|
['expand-properties', 'show-text', 'Subtitle delay: ${sub-delay}', '3000'],
|
|
]);
|
|
});
|
|
|
|
test('showMpvOsdRuntime logs fallback when disconnected', () => {
|
|
const logs: string[] = [];
|
|
const shown = showMpvOsdRuntime(
|
|
{
|
|
connected: false,
|
|
send: () => {},
|
|
},
|
|
'hello',
|
|
(line) => {
|
|
logs.push(line);
|
|
},
|
|
);
|
|
assert.equal(shown, false);
|
|
assert.deepEqual(logs, ['OSD (MPV not connected): hello']);
|
|
});
|