summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-30 20:00:46 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-30 20:00:46 -0500
commit338d210b66006189a0b775e8bd524c1cc11c2d9a (patch)
tree12fbd7eb03dcbb7ffcf270a1e7f9a8ee0cf53996 /test
parent43bc4e3015a7b6c4f4941c4b6327a7445b356f1c (diff)
Update paths
Diffstat (limited to 'test')
-rw-r--r--test/anki-note-builder.test.js6
-rw-r--r--test/database.test.js5
-rw-r--r--test/deinflector.test.js5
-rw-r--r--test/dom-text-scanner.test.js4
4 files changed, 14 insertions, 6 deletions
diff --git a/test/anki-note-builder.test.js b/test/anki-note-builder.test.js
index e4af7943..96dacab6 100644
--- a/test/anki-note-builder.test.js
+++ b/test/anki-note-builder.test.js
@@ -26,12 +26,14 @@ import {TranslatorVM} from '../dev/translator-vm.js';
import {AnkiNoteBuilder} from '../ext/js/data/anki-note-builder.js';
import {JapaneseUtil} from '../ext/js/language/sandbox/japanese-util.js';
+const dirname = path.dirname(fileURLToPath(import.meta.url));
+
/**
* @param {string} url2
* @returns {Promise<import('dev/vm').PseudoFetchResponse>}
*/
async function fetch(url2) {
- const extDir = path.join(__dirname, '..', 'ext');
+ const extDir = path.join(dirname, '..', 'ext');
let filePath;
try {
filePath = url.fileURLToPath(url2);
@@ -51,8 +53,6 @@ async function fetch(url2) {
vi.stubGlobal('fetch', fetch);
vi.mock('../ext/js/templates/template-renderer-proxy.js');
-const dirname = path.dirname(fileURLToPath(import.meta.url));
-
/**
* @returns {Promise<TranslatorVM>}
*/
diff --git a/test/database.test.js b/test/database.test.js
index ee818467..30854d55 100644
--- a/test/database.test.js
+++ b/test/database.test.js
@@ -18,12 +18,15 @@
import {IDBFactory, IDBKeyRange} from 'fake-indexeddb';
import path from 'path';
+import {fileURLToPath} from 'node:url';
import {beforeEach, describe, expect, test, vi} from 'vitest';
import {createDictionaryArchive} from '../dev/util.js';
import {DictionaryDatabase} from '../ext/js/language/dictionary-database.js';
import {DictionaryImporterMediaLoader} from '../ext/js/language/dictionary-importer-media-loader.js';
import {DictionaryImporter} from '../ext/js/language/dictionary-importer.js';
+const dirname = path.dirname(fileURLToPath(import.meta.url));
+
vi.stubGlobal('IDBKeyRange', IDBKeyRange);
vi.mock('../ext/js/language/dictionary-importer-media-loader.js');
@@ -34,7 +37,7 @@ vi.mock('../ext/js/language/dictionary-importer-media-loader.js');
* @returns {import('jszip')}
*/
function createTestDictionaryArchive(dictionary, dictionaryName) {
- const dictionaryDirectory = path.join(__dirname, 'data', 'dictionaries', dictionary);
+ const dictionaryDirectory = path.join(dirname, 'data', 'dictionaries', dictionary);
return createDictionaryArchive(dictionaryDirectory, dictionaryName);
}
diff --git a/test/deinflector.test.js b/test/deinflector.test.js
index 77184799..a69f8e56 100644
--- a/test/deinflector.test.js
+++ b/test/deinflector.test.js
@@ -20,6 +20,9 @@ import fs from 'fs';
import path from 'path';
import {describe, expect, test} from 'vitest';
import {Deinflector} from '../ext/js/language/deinflector.js';
+import {fileURLToPath} from 'node:url';
+
+const dirname = path.dirname(fileURLToPath(import.meta.url));
/**
* @param {Deinflector} deinflector
@@ -924,7 +927,7 @@ function testDeinflections() {
}
];
- const deinflectionReasons = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'}));
+ const deinflectionReasons = JSON.parse(fs.readFileSync(path.join(dirname, '..', 'ext', 'data/deinflect.json'), {encoding: 'utf8'}));
const deinflector = new Deinflector(deinflectionReasons);
describe('deinflections', () => {
diff --git a/test/dom-text-scanner.test.js b/test/dom-text-scanner.test.js
index 6d0c047b..30aec33e 100644
--- a/test/dom-text-scanner.test.js
+++ b/test/dom-text-scanner.test.js
@@ -19,9 +19,11 @@
import fs from 'fs';
import {JSDOM} from 'jsdom';
import path from 'path';
+import {fileURLToPath} from 'node:url';
import {expect, test} from 'vitest';
import {DOMTextScanner} from '../ext/js/dom/dom-text-scanner.js';
+const dirname = path.dirname(fileURLToPath(import.meta.url));
/**
* @param {string} fileName
@@ -188,7 +190,7 @@ async function testDomTextScanner(dom) {
/** */
async function testDocument1() {
- const dom = createJSDOM(path.join(__dirname, 'data', 'html', 'test-dom-text-scanner.html'));
+ const dom = createJSDOM(path.join(dirname, 'data', 'html', 'test-dom-text-scanner.html'));
const window = dom.window;
try {
window.getComputedStyle = createAbsoluteGetComputedStyle(window);