mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-26 16:19:26 -07:00
fix(character-dictionary): normalize fallback titles and wire close button
- Trim blank fallback titles in toAniListMediaCandidate; fall back to \"AniList <id>\" when all title fields and the fallback string are empty - Add fetch unit test covering the trimmed-fallback path - Extract wireDomEvents from createCharacterDictionaryModal so event listeners are bound explicitly after construction - Call wireDomEvents in renderer init alongside other modal wiring - Extend modal test to cover close-button click dismissing the modal
This commit is contained in:
29
src/main/character-dictionary-runtime/fetch.test.ts
Normal file
29
src/main/character-dictionary-runtime/fetch.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { searchAniListMediaCandidates } from './fetch';
|
||||
|
||||
test('searchAniListMediaCandidates trims fallback candidate titles', async () => {
|
||||
const previousFetch = globalThis.fetch;
|
||||
Object.defineProperty(globalThis, 'fetch', {
|
||||
configurable: true,
|
||||
value: async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
Page: {
|
||||
media: [{ id: 21355, episodes: 25, title: {} }],
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
try {
|
||||
const candidates = await searchAniListMediaCandidates(' Re:ZERO ');
|
||||
|
||||
assert.equal(candidates[0]?.title, 'Re:ZERO');
|
||||
} finally {
|
||||
Object.defineProperty(globalThis, 'fetch', { configurable: true, value: previousFetch });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user