mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-09 15:13:32 -07:00
Fix Windows mpv logging and add log export (#88)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { test } from 'node:test';
|
||||
import {
|
||||
CHARACTER_DICTIONARY_MANAGER_DISABLED_MESSAGE,
|
||||
openCharacterDictionaryManagerWithConfigGate,
|
||||
type CharacterDictionaryManagerNotificationType,
|
||||
} from './character-dictionary-manager-gate';
|
||||
|
||||
function makeDeps(options: {
|
||||
enabled?: boolean;
|
||||
notificationType?: CharacterDictionaryManagerNotificationType;
|
||||
}) {
|
||||
const calls: string[] = [];
|
||||
return {
|
||||
calls,
|
||||
deps: {
|
||||
isCharacterDictionaryEnabled: () => options.enabled ?? false,
|
||||
getNotificationType: () => options.notificationType ?? 'osd',
|
||||
openManager: () => calls.push('open'),
|
||||
showOsd: (message: string) => calls.push(`osd:${message}`),
|
||||
showDesktopNotification: (title: string, opts: { body: string }) =>
|
||||
calls.push(`system:${title}:${opts.body}`),
|
||||
logWarn: (message: string) => calls.push(`warn:${message}`),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('opens character dictionary manager when character dictionary is enabled', () => {
|
||||
const { calls, deps } = makeDeps({ enabled: true, notificationType: 'both' });
|
||||
|
||||
openCharacterDictionaryManagerWithConfigGate(deps);
|
||||
|
||||
assert.deepEqual(calls, ['open']);
|
||||
});
|
||||
|
||||
test('routes disabled manager notification to configured surfaces', () => {
|
||||
for (const [type, expected] of [
|
||||
['osd', [`osd:${CHARACTER_DICTIONARY_MANAGER_DISABLED_MESSAGE}`]],
|
||||
['system', [`system:SubMiner:${CHARACTER_DICTIONARY_MANAGER_DISABLED_MESSAGE}`]],
|
||||
[
|
||||
'both',
|
||||
[
|
||||
`osd:${CHARACTER_DICTIONARY_MANAGER_DISABLED_MESSAGE}`,
|
||||
`system:SubMiner:${CHARACTER_DICTIONARY_MANAGER_DISABLED_MESSAGE}`,
|
||||
],
|
||||
],
|
||||
['none', []],
|
||||
] as const) {
|
||||
const { calls, deps } = makeDeps({ enabled: false, notificationType: type });
|
||||
|
||||
openCharacterDictionaryManagerWithConfigGate(deps);
|
||||
|
||||
assert.deepEqual(calls, expected);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user