summaryrefslogtreecommitdiff
path: root/test/options-util.test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-16 19:33:24 -0500
committerGitHub <noreply@github.com>2024-02-17 00:33:24 +0000
commit1e69210b53151f31140bb1fbdc9f3d71fa181630 (patch)
treec8e824b531bf0fc46897ee7cf93fe375b5da946e /test/options-util.test.js
parent9432e4bb117869860db0aaa42a318fe73002d1c5 (diff)
Make vitests idiomatic (#677)
Diffstat (limited to 'test/options-util.test.js')
-rw-r--r--test/options-util.test.js53
1 files changed, 16 insertions, 37 deletions
diff --git a/test/options-util.test.js b/test/options-util.test.js
index c2050c3f..a178aecb 100644
--- a/test/options-util.test.js
+++ b/test/options-util.test.js
@@ -613,9 +613,22 @@ function createOptionsUpdatedTestData1() {
};
}
+/**
+ * @param {string} templates
+ * @returns {Map<string, string>}
+ */
+function getHandlebarsPartials(templates) {
+ const inlinePartialRegex = /{{~?#\*inline .*?"([^"]*)"~?}}.*?{{~?\/inline~?}}/gs;
+ const matches = templates.matchAll(inlinePartialRegex);
+ const partials = new Map();
+ for (const match of matches) {
+ const [template, name] = match;
+ partials.set(name, template);
+ }
+ return partials;
+}
-/** */
-async function testUpdate() {
+describe('OptionsUtil', () => {
test('Update', async () => {
const optionsUtil = new OptionsUtil();
await optionsUtil.prepare();
@@ -625,24 +638,7 @@ async function testUpdate() {
const optionsExpected = createOptionsUpdatedTestData1();
expect(optionsUpdated).toStrictEqual(optionsExpected);
});
-}
-/** */
-async function testCumulativeFieldTemplatesUpdates() {
- /**
- * @param {string} templates
- * @returns {Map<string, string>}
- */
- const getHandlebarsPartials = (templates) => {
- const inlinePartialRegex = /{{~?#\*inline .*?"([^"]*)"~?}}.*?{{~?\/inline~?}}/gs;
- const matches = templates.matchAll(inlinePartialRegex);
- const partials = new Map();
- for (const match of matches) {
- const [template, name] = match;
- partials.set(name, template);
- }
- return partials;
- };
test('CumulativeFieldTemplatesUpdates', async () => {
const optionsUtil = new OptionsUtil();
await optionsUtil.prepare();
@@ -661,10 +657,7 @@ async function testCumulativeFieldTemplatesUpdates() {
expect(partialsUpdated).toStrictEqual(partialsExpected);
});
-}
-/** */
-async function testDefault() {
describe('Default', () => {
/** @type {((options: import('options-util').IntermediateOptions) => void)[]} */
const data = [
@@ -688,10 +681,7 @@ async function testDefault() {
expect(structuredClone(optionsUpdated)).toStrictEqual(structuredClone(options));
});
});
-}
-/** */
-async function testFieldTemplatesUpdate() {
describe('FieldTemplatesUpdate', () => {
const templatePatcher = new TemplatePatcher();
/**
@@ -1725,15 +1715,4 @@ async function testFieldTemplatesUpdate() {
expect(fieldTemplatesActual).toStrictEqual(expected2);
});
});
-}
-
-
-/** */
-async function main() {
- await testUpdate();
- await testDefault();
- await testFieldTemplatesUpdate();
- await testCumulativeFieldTemplatesUpdates();
-}
-
-await main();
+});