From 9935e154f1d2d9881c636b9a93f9d31b04621287 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 6 Jul 2021 22:59:24 -0400 Subject: Update options-util tests and comment (#1806) --- ext/js/data/options-util.js | 1 + test/test-options-util.js | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 4bd5e7af..baa727d2 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -853,6 +853,7 @@ class OptionsUtil { async _updateVersion13(options) { // Version 13 changes: // Handlebars templates updated to use formatGlossary. + // Handlebars templates updated to use new media format. await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v13.handlebars'); return options; } diff --git a/test/test-options-util.js b/test/test-options-util.js index b942c66f..15a11265 100644 --- a/test/test-options-util.js +++ b/test/test-options-util.js @@ -661,7 +661,7 @@ async function testFieldTemplatesUpdate(extDir) { const getUpdateAdditions = (startVersion, targetVersion) => { let value = ''; for (const {version, changes} of updates) { - if (version < startVersion || version > targetVersion || changes.length === 0) { continue; } + if (version <= startVersion || version > targetVersion || changes.length === 0) { continue; } if (value.length > 0) { value += '\n'; } value += changes; } @@ -936,22 +936,30 @@ async function testFieldTemplatesUpdate(extDir) { oldVersion: 12, newVersion: 13, old: ` +{{#*inline "example"}} {{~#if (op "<=" glossary.length 1)~}} {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{/each}} {{~else if @root.compactGlossaries~}} {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{#unless @last}} | {{/unless}}{{/each}} {{~else~}} - {{~/if~}}`.trimStart(), + {{~/if~}} +{{/inline}} + +{{~> (lookup . "marker") ~}}`.trimStart(), expected: ` +{{#*inline "example"}} {{~#if (op "<=" glossary.length 1)~}} {{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{/each}} {{~else if @root.compactGlossaries~}} {{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{#unless @last}} | {{/unless}}{{/each}} {{~else~}} - {{~/if~}}`.trimStart() + {{~/if~}} +{{/inline}} + +{{~> (lookup . "marker") ~}}`.trimStart() }, // hasMedia/getMedia update { @@ -976,7 +984,9 @@ async function testFieldTemplatesUpdate(extDir) { {{#*inline "clipboard-text"}} {{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}} -{{/inline}}`.trimStart(), +{{/inline}} + +{{~> (lookup . "marker") ~}}`.trimStart(), expected: ` {{#*inline "audio"}} @@ -999,7 +1009,9 @@ async function testFieldTemplatesUpdate(extDir) { {{#*inline "clipboard-text"}} {{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText" format="text"}}{{/getMedia}}{{/if~}} -{{/inline}}`.trimStart() +{{/inline}} + +{{~> (lookup . "marker") ~}}`.trimStart() } ]; -- cgit v1.2.3