summaryrefslogtreecommitdiff
path: root/test/options-util.test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-20 00:47:15 -0500
committerGitHub <noreply@github.com>2023-12-20 05:47:15 +0000
commit8b943cc97fab890085448122e7c13dd035d0e238 (patch)
treea7a749a44771c6a82b1b72bb35cc0c81d57ddb54 /test/options-util.test.js
parentb13fbd47941fc20cf623871396e34a6dfe9b4dba (diff)
JSON validation (#394)
* Set up JSON testing * Add schema validation * Use parseJson * Finish types * Disambiguate ext/json-schema from node dependency with the same name * Add support for specifying the jsconfig file * Don't expose types * Update types * Use dictionary map type * Fix types * Fix AJV warnings * Move types * Move anb rename file * Move common mocks * Simplify types
Diffstat (limited to 'test/options-util.test.js')
-rw-r--r--test/options-util.test.js29
1 files changed, 2 insertions, 27 deletions
diff --git a/test/options-util.test.js b/test/options-util.test.js
index 41185756..7bb9767a 100644
--- a/test/options-util.test.js
+++ b/test/options-util.test.js
@@ -19,40 +19,15 @@
/* eslint-disable no-multi-spaces */
import fs from 'fs';
-import url, {fileURLToPath} from 'node:url';
+import {fileURLToPath} from 'node:url';
import path from 'path';
import {expect, test, vi} from 'vitest';
-import {parseJson} from '../dev/json.js';
import {OptionsUtil} from '../ext/js/data/options-util.js';
import {TemplatePatcher} from '../ext/js/templates/template-patcher.js';
+import {chrome, fetch} from './mocks/common.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
-/**
- * @param {string} url2
- * @returns {Promise<import('dev/vm').PseudoFetchResponse>}
- */
-async function fetch(url2) {
- const filePath = url.fileURLToPath(url2);
- await Promise.resolve();
- const content = fs.readFileSync(filePath, {encoding: null});
- return {
- ok: true,
- status: 200,
- statusText: 'OK',
- text: async () => Promise.resolve(content.toString('utf8')),
- json: async () => Promise.resolve(parseJson(content.toString('utf8')))
- };
-}
-/** @type {import('dev/vm').PseudoChrome} */
-const chrome = {
- runtime: {
- getURL(path2) {
- return url.pathToFileURL(path.join(dirname, '..', 'ext', path2.replace(/^\//, ''))).href;
- }
- }
-};
-
vi.stubGlobal('fetch', fetch);
vi.stubGlobal('chrome', chrome);