mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-07 13:08:54 -07:00
feat: add Anki deck dropdown with Yomitan auto-fill in settings (#95)
This commit is contained in:
@@ -6,6 +6,7 @@ import test from 'node:test';
|
||||
import * as vm from 'node:vm';
|
||||
import {
|
||||
addYomitanNoteViaSearch,
|
||||
extractYomitanCurrentAnkiDeckName,
|
||||
getYomitanDictionaryInfo,
|
||||
importYomitanDictionaryFromZip,
|
||||
deleteYomitanDictionaryByTitle,
|
||||
@@ -181,6 +182,72 @@ test('syncYomitanDefaultAnkiServer no-ops for empty target url', async () => {
|
||||
assert.equal(executeCount, 0);
|
||||
});
|
||||
|
||||
test('extractYomitanCurrentAnkiDeckName prefers the active profile first term card format deck', () => {
|
||||
assert.equal(
|
||||
extractYomitanCurrentAnkiDeckName({
|
||||
profileCurrent: 1,
|
||||
profiles: [
|
||||
{
|
||||
options: {
|
||||
anki: {
|
||||
cardFormats: [{ type: 'term', deck: 'Inactive' }],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
options: {
|
||||
anki: {
|
||||
cardFormats: [
|
||||
{ type: 'kanji', deck: 'Kanji' },
|
||||
{ type: 'term', deck: 'Mining' },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
'Mining',
|
||||
);
|
||||
});
|
||||
|
||||
test('extractYomitanCurrentAnkiDeckName ignores disabled card format decks', () => {
|
||||
assert.equal(
|
||||
extractYomitanCurrentAnkiDeckName({
|
||||
profiles: [
|
||||
{
|
||||
options: {
|
||||
anki: {
|
||||
cardFormats: [
|
||||
{ type: 'term', deck: 'Disabled Term', enabled: false },
|
||||
{ type: 'kanji', deck: 'Disabled Kanji', enabled: false },
|
||||
{ type: 'term', deck: 'Mining', enabled: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
'Mining',
|
||||
);
|
||||
});
|
||||
|
||||
test('extractYomitanCurrentAnkiDeckName falls back to legacy term deck', () => {
|
||||
assert.equal(
|
||||
extractYomitanCurrentAnkiDeckName({
|
||||
profiles: [
|
||||
{
|
||||
options: {
|
||||
anki: {
|
||||
terms: { deck: 'Legacy Mining' },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
'Legacy Mining',
|
||||
);
|
||||
});
|
||||
|
||||
test('requestYomitanTermFrequencies returns normalized frequency entries', async () => {
|
||||
let scriptValue = '';
|
||||
const deps = createDeps(async (script) => {
|
||||
|
||||
Reference in New Issue
Block a user