summaryrefslogtreecommitdiff
path: root/test/deinflector.test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:53:22 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:53:22 -0500
commitf0c5ef69ca1758d5ef9201bc8a4375e5933888be (patch)
treedfbc206fccaac88d59dac7ed90eca87f5fc8044d /test/deinflector.test.js
parentbfcc9d3fba4a3ff85be167eb771a4c0f26f9cc49 (diff)
Update types
Diffstat (limited to 'test/deinflector.test.js')
-rw-r--r--test/deinflector.test.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/deinflector.test.js b/test/deinflector.test.js
index edb85833..77184799 100644
--- a/test/deinflector.test.js
+++ b/test/deinflector.test.js
@@ -21,8 +21,16 @@ import path from 'path';
import {describe, expect, test} from 'vitest';
import {Deinflector} from '../ext/js/language/deinflector.js';
+/**
+ * @param {Deinflector} deinflector
+ * @param {string} source
+ * @param {string} expectedTerm
+ * @param {string} expectedRule
+ * @param {string[]|undefined} expectedReasons
+ * @returns {{has: false, reasons: null, rules: null}|{has: true, reasons: string[], rules: number}}
+ */
function hasTermReasons(deinflector, source, expectedTerm, expectedRule, expectedReasons) {
- for (const {term, reasons, rules} of deinflector.deinflect(source, source)) {
+ for (const {term, reasons, rules} of deinflector.deinflect(source)) {
if (term !== expectedTerm) { continue; }
if (typeof expectedRule !== 'undefined') {
const expectedFlags = Deinflector.rulesToRuleFlags([expectedRule]);
@@ -46,6 +54,7 @@ function hasTermReasons(deinflector, source, expectedTerm, expectedRule, expecte
}
+/** */
function testDeinflections() {
const data = [
{
@@ -915,7 +924,7 @@ function testDeinflections() {
}
];
- const deinflectionReasons = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'ext', 'data/deinflect.json')));
+ const deinflectionReasons = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'}));
const deinflector = new Deinflector(deinflectionReasons);
describe('deinflections', () => {
@@ -939,6 +948,7 @@ function testDeinflections() {
}
+/** */
function main() {
testDeinflections();
}