aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-18 04:53:48 -0500
committerGitHub <noreply@github.com>2023-12-18 09:53:48 +0000
commitd594d49ea81e1b546b6e39b7f85f098d9dc6fc48 (patch)
tree4834de07e2aec8bcde3cd165357415f67f4c5140
parentb249627434d3a94420ac4d98c3ce720767e57b43 (diff)
Mock updates (#370)
* Move DictionaryImporterMediaLoader mock * Move TemplateRendererProxy mock * Simplify mock * Remove ignore rule because it seems unused
-rw-r--r--.gitignore1
-rw-r--r--dev/translator-vm.js2
-rw-r--r--test/anki-note-builder.test.js2
-rw-r--r--test/database.test.js4
-rw-r--r--test/mocks/dictionary-importer-media-loader.js (renamed from ext/js/language/__mocks__/dictionary-importer-media-loader.js)0
-rw-r--r--test/mocks/template-renderer-proxy.js (renamed from ext/js/templates/__mocks__/template-renderer-proxy.js)2
6 files changed, 4 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 3941db60..459af2b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,5 @@ dictionaries/
ext/manifest.json
ext/lib/*
-!ext/lib/__mocks__/
ext/legal-npm.html
diff --git a/dev/translator-vm.js b/dev/translator-vm.js
index 7fdda879..60777da0 100644
--- a/dev/translator-vm.js
+++ b/dev/translator-vm.js
@@ -28,7 +28,7 @@ import {JapaneseUtil} from '../ext/js/language/sandbox/japanese-util.js';
import {Translator} from '../ext/js/language/translator.js';
import {createDictionaryArchive} from './util.js';
-vi.mock('../ext/js/language/dictionary-importer-media-loader.js');
+vi.mock('../ext/js/language/dictionary-importer-media-loader.js', async () => await import('../test/mocks/dictionary-importer-media-loader.js'));
const dirname = path.dirname(fileURLToPath(import.meta.url));
diff --git a/test/anki-note-builder.test.js b/test/anki-note-builder.test.js
index 6901dde9..42ee2290 100644
--- a/test/anki-note-builder.test.js
+++ b/test/anki-note-builder.test.js
@@ -53,7 +53,7 @@ async function fetch(url2) {
};
}
vi.stubGlobal('fetch', fetch);
-vi.mock('../ext/js/templates/template-renderer-proxy.js');
+vi.mock('../ext/js/templates/template-renderer-proxy.js', async () => await import('../test/mocks/template-renderer-proxy.js'));
/**
* @returns {Promise<TranslatorVM>}
diff --git a/test/database.test.js b/test/database.test.js
index e7774d95..2fdea99c 100644
--- a/test/database.test.js
+++ b/test/database.test.js
@@ -22,15 +22,13 @@ import path from 'path';
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';
+import {DictionaryImporterMediaLoader} from './mocks/dictionary-importer-media-loader.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
vi.stubGlobal('IDBKeyRange', IDBKeyRange);
-vi.mock('../ext/js/language/dictionary-importer-media-loader.js');
-
/**
* @param {string} dictionary
* @param {string} [dictionaryName]
diff --git a/ext/js/language/__mocks__/dictionary-importer-media-loader.js b/test/mocks/dictionary-importer-media-loader.js
index ffda29b3..ffda29b3 100644
--- a/ext/js/language/__mocks__/dictionary-importer-media-loader.js
+++ b/test/mocks/dictionary-importer-media-loader.js
diff --git a/ext/js/templates/__mocks__/template-renderer-proxy.js b/test/mocks/template-renderer-proxy.js
index 8823e8f3..106cdb35 100644
--- a/ext/js/templates/__mocks__/template-renderer-proxy.js
+++ b/test/mocks/template-renderer-proxy.js
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import {AnkiTemplateRenderer} from '../sandbox/anki-template-renderer.js';
+import {AnkiTemplateRenderer} from '../../ext/js/templates/sandbox/anki-template-renderer.js';
export class TemplateRendererProxy {
constructor() {