summaryrefslogtreecommitdiff
path: root/test/deinflector.test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 00:33:38 -0500
committerGitHub <noreply@github.com>2023-12-19 05:33:38 +0000
commit1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch)
tree305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /test/deinflector.test.js
parent5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff)
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types
Diffstat (limited to 'test/deinflector.test.js')
-rw-r--r--test/deinflector.test.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/deinflector.test.js b/test/deinflector.test.js
index adb347f1..1d7a39cf 100644
--- a/test/deinflector.test.js
+++ b/test/deinflector.test.js
@@ -22,6 +22,7 @@ import fs from 'fs';
import {fileURLToPath} from 'node:url';
import path from 'path';
import {describe, expect, test} from 'vitest';
+import {parseJson} from '../dev/json.js';
import {Deinflector} from '../ext/js/language/deinflector.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -929,7 +930,8 @@ function testDeinflections() {
}
];
- const deinflectionReasons = JSON.parse(fs.readFileSync(path.join(dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'}));
+ /** @type {import('deinflector').ReasonsRaw} */
+ const deinflectionReasons = parseJson(fs.readFileSync(path.join(dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'}));
const deinflector = new Deinflector(deinflectionReasons);
describe('deinflections', () => {