Files
SubMiner/src/main/runtime/mining-actions-main-deps.test.ts
T
sudacode 4677f5624b fix(stats): count mined cards once and keep lexical stats exact after deletes
- Card creation now owns mined-card counting; remove the outer single and
  multi-line mining increments that double counted each card.
- Preserve fractional first_seen/last_seen precision when session deletes
  compare and refresh lexical aggregates.
- Derive vocabulary_visible from the stored word row on every write so the
  new-word charts agree with the filtered vocabulary summary.
- Bump the lexical rollup version so existing databases re-derive visibility
  and repair stale last_seen values once in the background worker.
2026-10-01 22:56:38 -07:00

73 lines
2.5 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
createBuildCopyCurrentSubtitleMainDepsHandler,
createBuildHandleMineSentenceDigitMainDepsHandler,
createBuildHandleMultiCopyDigitMainDepsHandler,
} from './mining-actions-main-deps';
test('mining action main deps builders map callbacks', () => {
const calls: string[] = [];
const multiCopy = createBuildHandleMultiCopyDigitMainDepsHandler({
getSubtitleTimingTracker: () => ({ track: true }),
writeClipboardText: (text) => calls.push(`clip:${text}`),
showMpvOsd: (text) => calls.push(`osd:${text}`),
handleMultiCopyDigitCore: () => calls.push('multi-copy'),
})();
assert.deepEqual(multiCopy.getSubtitleTimingTracker(), { track: true });
multiCopy.writeClipboardText('x');
multiCopy.showMpvOsd('y');
multiCopy.handleMultiCopyDigitCore(2, {
subtitleTimingTracker: { track: true },
writeClipboardText: () => {},
showMpvOsd: () => {},
});
const copyCurrent = createBuildCopyCurrentSubtitleMainDepsHandler({
getSubtitleTimingTracker: () => ({ track: true }),
writeClipboardText: (text) => calls.push(`copy:${text}`),
showMpvOsd: (text) => calls.push(`copy-osd:${text}`),
copyCurrentSubtitleCore: () => calls.push('copy-current'),
})();
assert.deepEqual(copyCurrent.getSubtitleTimingTracker(), { track: true });
copyCurrent.writeClipboardText('a');
copyCurrent.showMpvOsd('b');
copyCurrent.copyCurrentSubtitleCore({
subtitleTimingTracker: { track: true },
writeClipboardText: () => {},
showMpvOsd: () => {},
});
const mineDigit = createBuildHandleMineSentenceDigitMainDepsHandler({
getSubtitleTimingTracker: () => ({ track: true }),
getAnkiIntegration: () => ({ enabled: true }),
getCurrentSecondarySubText: () => 'sub',
showMpvOsd: (text) => calls.push(`mine-osd:${text}`),
logError: (message) => calls.push(`err:${message}`),
handleMineSentenceDigitCore: () => calls.push('mine-digit'),
})();
assert.equal(mineDigit.getCurrentSecondarySubText(), 'sub');
mineDigit.showMpvOsd('done');
mineDigit.logError('bad', null);
mineDigit.handleMineSentenceDigitCore(2, {
subtitleTimingTracker: { track: true },
ankiIntegration: { enabled: true },
getCurrentSecondarySubText: () => 'sub',
showMpvOsd: () => {},
logError: () => {},
});
assert.deepEqual(calls, [
'clip:x',
'osd:y',
'multi-copy',
'copy:a',
'copy-osd:b',
'copy-current',
'mine-osd:done',
'err:bad',
'mine-digit',
]);
});