aboutsummaryrefslogtreecommitdiff
path: root/test/reading
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-07-16 12:34:50 +0200
committerlonkaars <loek@pipeframe.xyz>2023-07-16 12:34:50 +0200
commit63e2f87e716694c58d771640db0a14f32f5f1040 (patch)
tree9deac224129391731260382977ab450a5ed91f8a /test/reading
parent8e179a43e909ce4683f753a90bb3505630f05ad8 (diff)
use character-by-character diffs for reading tests + skip split reading checks
Diffstat (limited to 'test/reading')
-rw-r--r--test/reading/test.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/reading/test.ts b/test/reading/test.ts
index c1e7de4..e178543 100644
--- a/test/reading/test.ts
+++ b/test/reading/test.ts
@@ -1,12 +1,20 @@
-import { api, assertEquals, formatCaseIndex } from "../base.ts";
+import YomikunError from "../../util/error.ts";
+import { api, assertStrDiffMsg, formatCaseIndex } from "../base.ts";
import cases from "./cases.ts";
-cases.forEach(({input, output}, i) => {
+cases.forEach((test, i) => {
// if (i != 1) return;
- Deno.test(`Sentence reading ${formatCaseIndex(i, cases.length)} - ${input}`, async () => {
- // TODO: use sentence reading and tags
- var sentence = await api.sentence(input);
- assertEquals(sentence.furigana("refold-tools"), output);
+ Deno.test(`Sentence reading ${formatCaseIndex(i, cases.length)} - ${test.input}`, async () => {
+ // TODO: use domain/series tags
+ var sentence = await api.sentence(test.input);
+
+ const actual = sentence.furigana("refold-tools");
+ const expected = test.output;
+
+ // reading-only check (skip split reading across multiple kanji check)
+ if (sentence.reading != test.reading && actual != expected) {
+ throw new YomikunError(assertStrDiffMsg(expected, actual));
+ }
});
});