mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-14 13:55:55 -07:00
Add inline character portraits and dictionary search workflow (#83)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyCollapsibleOpenStatesToTermEntries } from './build';
|
||||
import type { CharacterDictionaryTermEntry } from './types';
|
||||
import { applyCollapsibleOpenStatesToTermEntries, buildSnapshotFromCharacters } from './build';
|
||||
import type { CharacterDictionaryTermEntry, CharacterRecord } from './types';
|
||||
|
||||
test('applyCollapsibleOpenStatesToTermEntries reapplies configured details open states', () => {
|
||||
const termEntries: CharacterDictionaryTermEntry[] = [
|
||||
@@ -56,3 +56,66 @@ test('applyCollapsibleOpenStatesToTermEntries reapplies configured details open
|
||||
assert.equal(glossaryEntry.content.content[0]?.open, true);
|
||||
assert.equal(glossaryEntry.content.content[1]?.open, false);
|
||||
});
|
||||
|
||||
test('buildSnapshotFromCharacters shows Japanese aliases without adding romanized names as lookup entries', () => {
|
||||
const character: CharacterRecord = {
|
||||
id: 1,
|
||||
role: 'main',
|
||||
firstNameHint: '',
|
||||
fullName: 'Aqua',
|
||||
lastNameHint: '',
|
||||
nativeName: 'アクア',
|
||||
alternativeNames: ['阿久亜'],
|
||||
bloodType: '',
|
||||
birthday: null,
|
||||
description: '',
|
||||
imageUrl: null,
|
||||
age: '',
|
||||
sex: '',
|
||||
voiceActors: [],
|
||||
};
|
||||
|
||||
const snapshot = buildSnapshotFromCharacters(
|
||||
100,
|
||||
'KonoSuba',
|
||||
[character],
|
||||
new Map(),
|
||||
new Map(),
|
||||
1_700_000_000_000,
|
||||
() => false,
|
||||
);
|
||||
|
||||
const aquaEntry = snapshot.termEntries.find(([term]) => term === 'アクア');
|
||||
assert.ok(aquaEntry);
|
||||
const glossaryEntry = aquaEntry[5][0] as {
|
||||
content: {
|
||||
content: Array<{ content?: unknown }>;
|
||||
};
|
||||
};
|
||||
const wholeGlossary = JSON.stringify(glossaryEntry);
|
||||
|
||||
const knownNames = glossaryEntry.content.content.find((node) => {
|
||||
const content = node.content;
|
||||
return (
|
||||
Array.isArray(content) &&
|
||||
content.some(
|
||||
(child) =>
|
||||
child &&
|
||||
typeof child === 'object' &&
|
||||
(child as { content?: unknown }).content === 'Known names',
|
||||
)
|
||||
);
|
||||
}) as { content: Array<{ content?: unknown }> } | undefined;
|
||||
assert.ok(knownNames, 'expected a Known names block in the character glossary');
|
||||
const knownNameItems = JSON.stringify(knownNames.content);
|
||||
const terms = snapshot.termEntries.map(([term]) => term);
|
||||
|
||||
assert.match(knownNameItems, /アクア/);
|
||||
assert.match(knownNameItems, /阿久亜/);
|
||||
assert.doesNotMatch(wholeGlossary, /Aqua/);
|
||||
assert.doesNotMatch(knownNameItems, /Aqua/);
|
||||
assert.doesNotMatch(knownNameItems, /アクア様/);
|
||||
assert.equal(terms.includes('Aqua'), false);
|
||||
assert.equal(terms.includes('アクア'), true);
|
||||
assert.equal(terms.includes('阿久亜'), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user