aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/json.json7
-rw-r--r--test/fixtures/translator-test.js4
-rw-r--r--test/language-transformer-cycles.test.js17
-rw-r--r--test/language-transformer.test.js2
4 files changed, 21 insertions, 9 deletions
diff --git a/test/data/json.json b/test/data/json.json
index c7c1d3aa..16ca6f01 100644
--- a/test/data/json.json
+++ b/test/data/json.json
@@ -93,7 +93,12 @@
"type": "AjvSchema"
},
{
- "path": "ext/data/language/japanese-transforms.json",
+ "path": "ext/js/language/ja/japanese-transforms.json",
+ "typeFile": "types/ext/language-transformer.d.ts",
+ "type": "LanguageTransformDescriptor"
+ },
+ {
+ "path": "ext/js/language/en/english-transforms.json",
"typeFile": "types/ext/language-transformer.d.ts",
"type": "LanguageTransformDescriptor"
},
diff --git a/test/fixtures/translator-test.js b/test/fixtures/translator-test.js
index ff3782a7..6b6eaad8 100644
--- a/test/fixtures/translator-test.js
+++ b/test/fixtures/translator-test.js
@@ -31,7 +31,7 @@ import {DictionaryImporterMediaLoader} from '../mocks/dictionary-importer-media-
import {createDomTest} from './dom-test.js';
const extDir = join(dirname(fileURLToPath(import.meta.url)), '../../ext');
-const languageTransformDescriptorPath = join(extDir, 'data/language/japanese-transforms.json');
+const languageTransformDescriptorPath = join(extDir, 'js/language/ja/japanese-transforms.json');
vi.stubGlobal('indexedDB', indexedDB);
vi.stubGlobal('IDBKeyRange', IDBKeyRange);
@@ -65,7 +65,7 @@ export async function createTranslatorContext(dictionaryDirectory, dictionaryNam
const translator = new Translator(dictionaryDatabase);
/** @type {import('language-transformer').LanguageTransformDescriptor} */
const deinflectionReasons = parseJson(readFileSync(languageTransformDescriptorPath, {encoding: 'utf8'}));
- translator.prepare(deinflectionReasons);
+ translator.prepare([deinflectionReasons]);
return translator;
}
diff --git a/test/language-transformer-cycles.test.js b/test/language-transformer-cycles.test.js
index b778c188..751f65a6 100644
--- a/test/language-transformer-cycles.test.js
+++ b/test/language-transformer-cycles.test.js
@@ -21,6 +21,7 @@ import {fileURLToPath} from 'url';
import {describe, test} from 'vitest';
import {parseJson} from '../dev/json.js';
import {LanguageTransformer} from '../ext/js/language/language-transformer.js';
+import {getLanguageSummaries} from '../ext/js/language/languages.js';
class DeinflectionNode {
/**
@@ -103,12 +104,18 @@ function arraysAreEqual(rules1, rules2) {
return true;
}
-describe('Deinflection data', () => {
- test('Check for cycles', ({expect}) => {
- const dirname = pathDirname(fileURLToPath(import.meta.url));
+const dirname = pathDirname(fileURLToPath(import.meta.url));
+const descriptors = [];
+const languageSummaries = getLanguageSummaries();
+for (const {languageTransformsFile} of languageSummaries) {
+ if (!languageTransformsFile) { continue; }
+ /** @type {import('language-transformer').LanguageTransformDescriptor} */
+ const descriptor = parseJson(readFileSync(join(dirname, `../ext/${languageTransformsFile}`), {encoding: 'utf8'}));
+ descriptors.push(descriptor);
+}
- /** @type {import('language-transformer').LanguageTransformDescriptor} */
- const descriptor = parseJson(readFileSync(join(dirname, '../ext/data/language/japanese-transforms.json'), {encoding: 'utf8'}));
+describe.each(descriptors)('Cycles Test $language', (descriptor) => {
+ test('Check for cycles', ({expect}) => {
const languageTransformer = new LanguageTransformer();
languageTransformer.addDescriptor(descriptor);
diff --git a/test/language-transformer.test.js b/test/language-transformer.test.js
index 7c0da48b..b682f66b 100644
--- a/test/language-transformer.test.js
+++ b/test/language-transformer.test.js
@@ -1147,7 +1147,7 @@ describe('LanguageTransformer', () => {
/* eslint-enable @stylistic/no-multi-spaces */
/** @type {import('language-transformer').LanguageTransformDescriptor} */
- const descriptor = parseJson(fs.readFileSync(path.join(dirname, '..', 'ext', 'data/language/japanese-transforms.json'), {encoding: 'utf8'}));
+ const descriptor = parseJson(fs.readFileSync(path.join(dirname, '..', 'ext', 'js/language/ja/japanese-transforms.json'), {encoding: 'utf8'}));
const languageTransformer = new LanguageTransformer();
languageTransformer.addDescriptor(descriptor);