aboutsummaryrefslogtreecommitdiff
path: root/test/options-util.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/options-util.test.js')
-rw-r--r--test/options-util.test.js27
1 files changed, 13 insertions, 14 deletions
diff --git a/test/options-util.test.js b/test/options-util.test.js
index 41743b9f..a34cc93a 100644
--- a/test/options-util.test.js
+++ b/test/options-util.test.js
@@ -21,7 +21,7 @@
import fs from 'fs';
import {fileURLToPath} from 'node:url';
import path from 'path';
-import {expect, test, vi} from 'vitest';
+import {expect, test, describe, vi} from 'vitest';
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';
@@ -628,7 +628,7 @@ async function testUpdate() {
/** */
async function testDefault() {
- test('Default', async () => {
+ describe('Default', () => {
/** @type {((options: import('options-util').IntermediateOptions) => void)[]} */
const data = [
(options) => options,
@@ -640,27 +640,22 @@ async function testDefault() {
}
];
- const optionsUtil = new OptionsUtil();
- await optionsUtil.prepare();
+ test.each(data)('default-test-%#', async (modify) => {
+ const optionsUtil = new OptionsUtil();
+ await optionsUtil.prepare();
- for (const modify of data) {
const options = optionsUtil.getDefault();
-
const optionsModified = structuredClone(options);
modify(optionsModified);
-
const optionsUpdated = await optionsUtil.update(structuredClone(optionsModified));
expect(structuredClone(optionsUpdated)).toStrictEqual(structuredClone(options));
- }
+ });
});
}
/** */
async function testFieldTemplatesUpdate() {
- test('FieldTemplatesUpdate', async () => {
- const optionsUtil = new OptionsUtil();
- await optionsUtil.prepare();
-
+ describe('FieldTemplatesUpdate', () => {
const templatePatcher = new TemplatePatcher();
/**
* @param {string} fileName
@@ -1577,7 +1572,11 @@ async function testFieldTemplatesUpdate() {
];
const updatesPattern = /<<<UPDATE-ADDITIONS>>>/g;
- for (const {old, expected, oldVersion, newVersion} of data) {
+
+ test.each(data)('field-templates-update-test-%#', async ({old, expected, oldVersion, newVersion}) => {
+ const optionsUtil = new OptionsUtil();
+ await optionsUtil.prepare();
+
const options = /** @type {import('core').SafeAny} */ (createOptionsTestData1());
options.profiles[0].options.anki.fieldTemplates = old;
options.version = oldVersion;
@@ -1587,7 +1586,7 @@ async function testFieldTemplatesUpdate() {
const optionsUpdated = structuredClone(await optionsUtil.update(options, newVersion));
const fieldTemplatesActual = optionsUpdated.profiles[0].options.anki.fieldTemplates;
expect(fieldTemplatesActual).toStrictEqual(expected2);
- }
+ });
});
}