mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
fix(anki): separate word audio mapping for animation sync (#256)
This commit is contained in:
1 parent
8097ed27e5
commit
05425cc5db
17 files changed
+97
-10
No files matched your search
@@ -290,6 +290,28 @@ test('accepts ankiConnect.media.syncAnimatedImageToWordAudio override', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('word audio mapping defaults and validates independently of sentence audio', () => {
|
||||
for (const wordAudio of [undefined, 'Pronunciation', 7]) {
|
||||
const { context, warnings } = makeContext({
|
||||
fields: {
|
||||
audio: 'SentenceAudio',
|
||||
...(wordAudio !== undefined ? { wordAudio } : {}),
|
||||
},
|
||||
});
|
||||
applyAnkiConnectResolution(context);
|
||||
|
||||
assert.equal(context.resolved.ankiConnect.fields.audio, 'SentenceAudio');
|
||||
assert.equal(
|
||||
context.resolved.ankiConnect.fields.wordAudio,
|
||||
typeof wordAudio === 'string' ? wordAudio : DEFAULT_CONFIG.ankiConnect.fields.wordAudio,
|
||||
);
|
||||
assert.deepEqual(
|
||||
warnings.map((warning) => warning.path),
|
||||
typeof wordAudio === 'number' ? ['ankiConnect.fields.wordAudio'] : [],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('invalid modern Anki subtrees warn and keep resolved defaults', () => {
|
||||
const { context, warnings } = makeContext({
|
||||
fields: { word: 7 },
|
||||
|
||||
@@ -7,7 +7,15 @@ export function applyModernFieldsResolution(
|
||||
context: ResolveContext,
|
||||
fields: Record<string, unknown>,
|
||||
): void {
|
||||
for (const key of ['word', 'audio', 'image', 'sentence', 'miscInfo', 'translation'] as const) {
|
||||
for (const key of [
|
||||
'word',
|
||||
'audio',
|
||||
'wordAudio',
|
||||
'image',
|
||||
'sentence',
|
||||
'miscInfo',
|
||||
'translation',
|
||||
] as const) {
|
||||
applyModernValue(
|
||||
context,
|
||||
fields,
|
||||
|
||||
Reference in new issue
Block a user