diff --git a/package-lock.json b/package-lock.json
index ab97d37404..c181804797 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5868,9 +5868,9 @@
"dev": true
},
"node_modules/vite": {
- "version": "5.0.10",
- "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz",
- "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==",
+ "version": "5.0.12",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz",
+ "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==",
"dev": true,
"dependencies": {
"esbuild": "^0.19.3",
@@ -10364,9 +10364,9 @@
"dev": true
},
"vite": {
- "version": "5.0.10",
- "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz",
- "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==",
+ "version": "5.0.12",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz",
+ "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==",
"dev": true,
"requires": {
"esbuild": "^0.19.3",
diff --git a/playwright.config.js b/playwright.config.js
index 6bf645c4d1..4658ceb2df 100644
--- a/playwright.config.js
+++ b/playwright.config.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 Yomitan Authors
+ * Copyright (C) 2023-2024 Yomitan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/test/anki-template-renderer.test.js b/test/anki-template-renderer.test.js
new file mode 100644
index 0000000000..d8d2a3b5c0
--- /dev/null
+++ b/test/anki-template-renderer.test.js
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2023-2024 Yomitan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
.
+ */
+
+import {describe} from 'vitest';
+import {createAnkiTemplateRendererTest} from './fixtures/anki-template-renderer-test.js';
+
+const test = await createAnkiTemplateRendererTest();
+
+describe('AnkiTemplateRenderer', () => {
+ /** @type {import('template-renderer').CompositeRenderData} */
+ const data = {
+ marker: 'test',
+ commonData: {
+ dictionaryEntry: {
+ type: 'kanji',
+ character: 'c',
+ dictionary: 'dictionary',
+ onyomi: [],
+ kunyomi: [],
+ tags: [],
+ stats: {},
+ definitions: [],
+ frequencies: []
+ },
+ resultOutputMode: 'split',
+ mode: 'test',
+ glossaryLayoutMode: 'default',
+ compactTags: false,
+ context: {
+ url: 'http://localhost/',
+ documentTitle: 'documentTitle',
+ query: 'query',
+ fullQuery: 'query.full',
+ sentence: {
+ text: 'sentence.query.full',
+ offset: 9
+ }
+ },
+ media: void 0
+ }
+ };
+ const testCases = [
+ {
+ name: 'regexMatch 1',
+ template: '{{#regexMatch "test" "gu"}}this is a test of regexMatch{{/regexMatch}}',
+ result: 'test'
+ },
+ {
+ name: 'regexMatch 2',
+ template: '{{regexMatch "test" "gu" "this is a test of regexMatch"}}',
+ result: 'test'
+ },
+ {
+ name: 'regexMatch 3',
+ template: '{{#if (regexMatch "test" "gu" "this is a test of regexMatch")}}true{{else}}false{{/if}}',
+ result: 'true'
+ },
+ {
+ name: 'regexReplace 1',
+ template: '{{#regexReplace "test" "TEST" "gu"}}this is a test of regexReplace{{/regexReplace}}',
+ result: 'this is a TEST of regexReplace'
+ },
+ {
+ name: 'regexReplace 2',
+ template: '{{regexReplace "test" "TEST" "gu" "this is a test of regexReplace"}}',
+ result: 'this is a TEST of regexReplace'
+ },
+ {
+ name: 'regexReplace 3',
+ template: '{{#if (regexReplace "test" "" "gu" "test")}}true{{else}}false{{/if}}',
+ result: 'false'
+ }
+ ];
+ describe.each(testCases)('$name', ({template, result: expectedResult}) => {
+ test('Test', ({expect, ankiTemplateRenderer}) => {
+ const {result} = ankiTemplateRenderer.templateRenderer.render(template, data, 'ankiNote');
+ expect(result).toEqual(expectedResult);
+ });
+ });
+});
diff --git a/test/cache-map.test.js b/test/cache-map.test.js
index 5db35cf0c5..72579f2558 100644
--- a/test/cache-map.test.js
+++ b/test/cache-map.test.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 Yomitan Authors
+ * Copyright (C) 2023-2024 Yomitan Authors
* Copyright (C) 2020-2022 Yomichan Authors
*
* This program is free software: you can redistribute it and/or modify
diff --git a/test/core.test.js b/test/core.test.js
index 127df78300..0ddcc2d1c9 100644
--- a/test/core.test.js
+++ b/test/core.test.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 Yomitan Authors
+ * Copyright (C) 2023-2024 Yomitan Authors
* Copyright (C) 2020-2022 Yomichan Authors
*
* This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,8 @@
*/
import {describe, expect, test} from 'vitest';
-import {DynamicProperty, deepEqual} from '../ext/js/core.js';
+import {DynamicProperty} from '../ext/js/core/dynamic-property.js';
+import {deepEqual} from '../ext/js/core/utilities.js';
/** */
function testDynamicProperty() {
diff --git a/test/css-json.test.js b/test/css-json.test.js
index 588651d280..b64419c31c 100644
--- a/test/css-json.test.js
+++ b/test/css-json.test.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 Yomitan Authors
+ * Copyright (C) 2023-2024 Yomitan Authors
* Copyright (C) 2021-2022 Yomichan Authors
*
* This program is free software: you can redistribute it and/or modify
diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json
index 86bffc6a0e..7129d74803 100644
--- a/test/data/anki-note-builder-test-results.json
+++ b/test/data/anki-note-builder-test-results.json
@@ -2867,5 +2867,41 @@
"url": "
url:"
}
]
+ },
+ {
+ "name": "Test dictionary deinflection",
+ "results": [
+ {
+ "audio": "",
+ "clipboard-image": "",
+ "clipboard-text": "",
+ "cloze-body": "のたもうた",
+ "cloze-prefix": "cloze-prefix",
+ "cloze-suffix": "cloze-suffix",
+ "conjugation": "past",
+ "dictionary": "Test Dictionary 2",
+ "document-title": "title",
+ "expression": "のたまう",
+ "frequencies": "",
+ "furigana": "のたまう",
+ "furigana-plain": "のたまう",
+ "glossary": "
(v5, Test Dictionary 2) notamau definition
",
+ "glossary-brief": "
notamau definition
",
+ "glossary-no-dictionary": "
(v5) notamau definition
",
+ "part-of-speech": "Godan verb",
+ "pitch-accents": "No pitch accent data",
+ "pitch-accent-graphs": "No pitch accent data",
+ "pitch-accent-positions": "No pitch accent data",
+ "phonetic-transcriptions": "",
+ "reading": "のたまう",
+ "screenshot": "",
+ "search-query": "fullQuery",
+ "selection-text": "",
+ "sentence": "cloze-prefixのたもうたcloze-suffix",
+ "sentence-furigana": "cloze-prefixのたもうたcloze-suffix",
+ "tags": "v5",
+ "url": "
url:"
+ }
+ ]
}
]
\ No newline at end of file
diff --git a/test/data/database-test-cases.json b/test/data/database-test-cases.json
index 02fddd4931..611903dd85 100644
--- a/test/data/database-test-cases.json
+++ b/test/data/database-test-cases.json
@@ -27,7 +27,7 @@
"ipa": 1
},
"terms": {
- "total": 23
+ "total": 25
}
}
},
@@ -36,7 +36,7 @@
{
"kanji": 2,
"kanjiMeta": 6,
- "terms": 23,
+ "terms": 25,
"termMeta": 39,
"tagMeta": 15,
"media": 6
@@ -45,7 +45,7 @@
"total": {
"kanji": 2,
"kanjiMeta": 6,
- "terms": 23,
+ "terms": 25,
"termMeta": 39,
"tagMeta": 15,
"media": 6
diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_bank_1.json
index ce4290bdff..7f2af6ddc9 100644
--- a/test/data/dictionaries/valid-dictionary1/term_bank_1.json
+++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json
@@ -337,5 +337,7 @@
{"type": "structured-content", "content": "kouzou definition 3 (構造)"}
],
101, "P E1"
- ]
+ ],
+ ["のたまう", "のたまう", "v5", "v5", 1, ["notamau definition"], 15, ""],
+ ["のたもうた", "のたもうた", "", "", 1, [["のたまう", ["past"]]], 16, ""]
]
\ No newline at end of file
diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_2.json b/test/data/dictionaries/valid-dictionary1/term_bank_2.json
index d46b4c144a..30e5418c09 100644
--- a/test/data/dictionaries/valid-dictionary1/term_bank_2.json
+++ b/test/data/dictionaries/valid-dictionary1/term_bank_2.json
@@ -103,6 +103,8 @@
{
"tag": "span",
"style": {
+ "color": "#dd2121",
+ "textShadow": "0.5px 0.5px 1px gray",
"textDecorationLine": "underline",
"textDecorationStyle": "wavy",
"textDecorationColor": "red"
diff --git a/test/data/html/dom-text-scanner.html b/test/data/html/dom-text-scanner.html
index ff4d0493fa..1f537d4e3b 100644
--- a/test/data/html/dom-text-scanner.html
+++ b/test/data/html/dom-text-scanner.html
@@ -392,4 +392,4 @@
DOMTextScanner Tests