aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/document-util.test.js3
-rw-r--r--test/dom-text-scanner.test.js10
-rw-r--r--test/eslint-config.test.js12
3 files changed, 17 insertions, 8 deletions
diff --git a/test/document-util.test.js b/test/document-util.test.js
index c2b2edca..0f541e12 100644
--- a/test/document-util.test.js
+++ b/test/document-util.test.js
@@ -206,12 +206,15 @@ describe('Document utility tests', () => {
// Sentence info
const terminatorString = '…。..??!!';
+ /** @type {import('text-scanner').SentenceTerminatorMap} */
const terminatorMap = new Map();
for (const char of terminatorString) {
terminatorMap.set(char, [false, true]);
}
const quoteArray = [['「', '」'], ['『', '』'], ['\'', '\''], ['"', '"']];
+ /** @type {import('text-scanner').SentenceForwardQuoteMap} */
const forwardQuoteMap = new Map();
+ /** @type {import('text-scanner').SentenceBackwardQuoteMap} */
const backwardQuoteMap = new Map();
for (const [char1, char2] of quoteArray) {
forwardQuoteMap.set(char1, [char2, false]);
diff --git a/test/dom-text-scanner.test.js b/test/dom-text-scanner.test.js
index 1ec7cab7..b366cadd 100644
--- a/test/dom-text-scanner.test.js
+++ b/test/dom-text-scanner.test.js
@@ -88,10 +88,16 @@ function createAbsoluteGetComputedStyle(window) {
get: (target, property) => {
let result = /** @type {import('core').SafeAny} */ (target)[property];
if (typeof result === 'string') {
- result = result.replace(/([-+]?\d(?:\.\d)?(?:[eE][-+]?\d+)?)em/g, (g0, g1) => {
+ /**
+ * @param {string} g0
+ * @param {string} g1
+ * @returns {string}
+ */
+ const replacer = (g0, g1) => {
const fontSize = getComputedFontSizeInPixels(window, getComputedStyleOld, element);
return `${Number.parseFloat(g1) * fontSize}px`;
- });
+ };
+ result = result.replace(/([-+]?\d(?:\.\d)?(?:[eE][-+]?\d+)?)em/g, replacer);
}
return result;
}
diff --git a/test/eslint-config.test.js b/test/eslint-config.test.js
index bddde695..47e347dd 100644
--- a/test/eslint-config.test.js
+++ b/test/eslint-config.test.js
@@ -55,8 +55,8 @@ function removeLibraryDependencies(dependencies) {
}
/**
- * @param {{[key: string]: boolean}|undefined} env1
- * @param {{[key: string]: boolean}} env2
+ * @param {import('test/eslint-config').MinimalEslintConfigEnv|undefined} env1
+ * @param {import('test/eslint-config').MinimalEslintConfigEnv} env2
* @returns {boolean}
*/
function envMatches(env1, env2) {
@@ -92,7 +92,7 @@ const targets = [
paths: [
'ext/js/templates/sandbox/template-renderer-frame-main.js'
],
- /** @type {{[key: string]: boolean}} */
+ /** @type {import('test/eslint-config').MinimalEslintConfigEnv} */
env: {
webextensions: false
}
@@ -102,7 +102,7 @@ const targets = [
paths: [
'ext/js/dictionary/dictionary-worker-main.js'
],
- /** @type {{[key: string]: boolean}} */
+ /** @type {import('test/eslint-config').MinimalEslintConfigEnv} */
env: {
browser: false,
worker: true
@@ -113,7 +113,7 @@ const targets = [
paths: [
'ext/js/background/background-main.js'
],
- /** @type {{[key: string]: boolean}} */
+ /** @type {import('test/eslint-config').MinimalEslintConfigEnv} */
env: {
browser: false,
serviceworker: true
@@ -123,7 +123,7 @@ const targets = [
describe('Eslint configuration', () => {
const eslintConfigPath = '.eslintrc.json';
- /** @type {import('core').SafeAny} */
+ /** @type {import('test/eslint-config').MinimalEslintConfig} */
const eslintConfig = parseJson(readFileSync(join(rootDir, eslintConfigPath), 'utf8'));
describe.each(targets)('Environment is $name', ({name, paths, env}) => {
test('Entry exists', async ({expect}) => {