aboutsummaryrefslogtreecommitdiff
path: root/test/options-util.test.js
diff options
context:
space:
mode:
authorCashew <52880648+Scrub1492@users.noreply.github.com>2024-01-14 10:51:00 +0700
committerGitHub <noreply@github.com>2024-01-14 03:51:00 +0000
commitdcb26a8ef5c62bf6acbf8130895c37f56e8a9d3f (patch)
tree6b25d1bebff154f9535f47b69ddc62263c7eeded /test/options-util.test.js
parent326c5335503d45daafe73daac88ae330c6bace77 (diff)
more test updates (#510)24.01.14.0
* test updates * remove duplicate * fix indentation * fix
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);
- }
+ });
});
}