summaryrefslogtreecommitdiff
path: root/test/database.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/database.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/database.test.js')
-rw-r--r--test/database.test.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/database.test.js b/test/database.test.js
index 2fdea99c..702de9f8 100644
--- a/test/database.test.js
+++ b/test/database.test.js
@@ -20,6 +20,7 @@ import {IDBFactory, IDBKeyRange} from 'fake-indexeddb';
import {fileURLToPath} from 'node:url';
import path from 'path';
import {beforeEach, describe, expect, test, vi} from 'vitest';
+import {parseJson} from '../dev/json.js';
import {createDictionaryArchive} from '../dev/util.js';
import {DictionaryDatabase} from '../ext/js/language/dictionary-database.js';
import {DictionaryImporter} from '../ext/js/language/dictionary-importer.js';
@@ -109,7 +110,8 @@ async function testDatabase1() {
// Load dictionary data
const testDictionary = createTestDictionaryArchive('valid-dictionary1');
const testDictionarySource = await testDictionary.generateAsync({type: 'arraybuffer'});
- const testDictionaryIndex = JSON.parse(await testDictionary.files['index.json'].async('string'));
+ /** @type {import('dictionary-data').Index} */
+ const testDictionaryIndex = parseJson(await testDictionary.files['index.json'].async('string'));
const title = testDictionaryIndex.title;
const titles = new Map([
@@ -852,7 +854,8 @@ async function testDatabase2() {
// Load dictionary data
const testDictionary = createTestDictionaryArchive('valid-dictionary1');
const testDictionarySource = await testDictionary.generateAsync({type: 'arraybuffer'});
- const testDictionaryIndex = JSON.parse(await testDictionary.files['index.json'].async('string'));
+ /** @type {import('dictionary-data').Index} */
+ const testDictionaryIndex = parseJson(await testDictionary.files['index.json'].async('string'));
const title = testDictionaryIndex.title;
const titles = new Map([