mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-30 07:21:32 -07:00
feat(stats): add Hide Kana filter and fix vocabulary exclusion matching
- Remove overlay mining image toast; OSD card notifications no longer flash a frame screenshot - Add Hide Kana toggle to frequency rank table to filter kana-only headwords - Fix vocab exclusions to deduplicate and match token variants (e.g. ない / 無い) under one exclusion entry - Skip cover image fetching when the overview tab is inactive
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { FrequencyRankTable } from './FrequencyRankTable';
|
||||
import {
|
||||
buildFrequencyRankRows,
|
||||
FrequencyRankTable,
|
||||
isKanaOnlyTokenText,
|
||||
} from './FrequencyRankTable';
|
||||
import type { VocabularyEntry } from '../../types/stats';
|
||||
|
||||
function makeEntry(over: Partial<VocabularyEntry>): VocabularyEntry {
|
||||
@@ -41,3 +45,42 @@ test('omits reading when reading equals headword', () => {
|
||||
'should not render any bracketed reading when equal to headword',
|
||||
);
|
||||
});
|
||||
|
||||
test('identifies kana-only token text without hiding mixed kanji words', () => {
|
||||
assert.equal(isKanaOnlyTokenText('さらに'), true);
|
||||
assert.equal(isKanaOnlyTokenText('バカ'), true);
|
||||
assert.equal(isKanaOnlyTokenText('カレー'), true);
|
||||
assert.equal(isKanaOnlyTokenText('前に'), false);
|
||||
assert.equal(isKanaOnlyTokenText('間違いない'), false);
|
||||
});
|
||||
|
||||
test('frequency rows can hide kana-only headwords', () => {
|
||||
const rows = buildFrequencyRankRows(
|
||||
[
|
||||
makeEntry({ wordId: 1, headword: 'さらに', word: 'さらに', frequencyRank: 10 }),
|
||||
makeEntry({
|
||||
wordId: 2,
|
||||
headword: '前に',
|
||||
word: '前に',
|
||||
reading: 'まえに',
|
||||
frequencyRank: 20,
|
||||
}),
|
||||
makeEntry({ wordId: 3, headword: 'バカ', word: 'バカ', reading: 'バカ', frequencyRank: 30 }),
|
||||
],
|
||||
new Set(),
|
||||
{ hideKnown: false, hideKanaOnly: true },
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
rows.map((row) => row.headword),
|
||||
['前に'],
|
||||
);
|
||||
});
|
||||
|
||||
test('renders a Hide Kana filter button', () => {
|
||||
const entry = makeEntry({ headword: 'さらに', word: 'さらに', reading: 'さらに' });
|
||||
const markup = renderToStaticMarkup(
|
||||
<FrequencyRankTable words={[entry]} knownWords={new Set()} />,
|
||||
);
|
||||
assert.match(markup, /Hide Kana/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user