summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpraschke <stel@comfy.monster>2023-10-17 22:25:30 +0100
committerpraschke <stel@comfy.monster>2023-10-17 22:25:30 +0100
commit9b798601b48a40b65e38b433924a99d155872ba7 (patch)
tree02ada4e52d83b4febfbf763b9cf1f1348c65e5cd /test
parent9f8269606fdf51765f6d13de4caac709691b0fea (diff)
update: hasMedia and getMedia
Diffstat (limited to 'test')
-rw-r--r--test/test-options-util.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/test/test-options-util.js b/test/test-options-util.js
index 78204de9..23cfc121 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -1480,6 +1480,88 @@ async function testFieldTemplatesUpdate(extDir) {
{{/inline}}
{{~> (lookup . "marker") ~}}`.trimStart()
+ },
+ // block helper update: hasMedia and getMedia
+ {
+ oldVersion: 20,
+ newVersion: 21,
+ old: `
+{{#*inline "audio"}}
+ {{~#if (hasMedia "audio")~}}
+ [sound:{{#getMedia "audio"}}{{/getMedia}}]
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "screenshot"}}
+ {{~#if (hasMedia "screenshot")~}}
+ <img src="{{#getMedia "screenshot"}}{{/getMedia}}" />
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-image"}}
+ {{~#if (hasMedia "clipboardImage")~}}
+ <img src="{{#getMedia "clipboardImage"}}{{/getMedia}}" />
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-text"}}
+ {{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText"}}{{/getMedia}}{{/if~}}
+{{/inline}}
+
+{{#*inline "selection-text"}}
+ {{~#if (hasMedia "selectionText")}}{{#getMedia "selectionText"}}{{/getMedia}}{{/if~}}
+{{/inline}}
+
+{{#*inline "sentence-furigana"}}
+ {{~#if definition.cloze~}}
+ {{~#if (hasMedia "textFurigana" definition.cloze.sentence)~}}
+ {{#getMedia "textFurigana" definition.cloze.sentence escape=false}}{{/getMedia}}
+ {{~else~}}
+ {{definition.cloze.sentence}}
+ {{~/if~}}
+ {{~/if~}}
+{{/inline}}
+
+{{~> (lookup . "marker") ~}}`.trimStart(),
+
+ expected: `
+{{#*inline "audio"}}
+ {{~#if (hasMedia "audio")~}}
+ [sound:{{getMedia "audio"}}]
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "screenshot"}}
+ {{~#if (hasMedia "screenshot")~}}
+ <img src="{{getMedia "screenshot"}}" />
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-image"}}
+ {{~#if (hasMedia "clipboardImage")~}}
+ <img src="{{getMedia "clipboardImage"}}" />
+ {{~/if~}}
+{{/inline}}
+
+{{#*inline "clipboard-text"}}
+ {{~#if (hasMedia "clipboardText")}}{{getMedia "clipboardText"}}{{/if~}}
+{{/inline}}
+
+{{#*inline "selection-text"}}
+ {{~#if (hasMedia "selectionText")}}{{getMedia "selectionText"}}{{/if~}}
+{{/inline}}
+
+{{#*inline "sentence-furigana"}}
+ {{~#if definition.cloze~}}
+ {{~#if (hasMedia "textFurigana" definition.cloze.sentence)~}}
+ {{getMedia "textFurigana" definition.cloze.sentence escape=false}}
+ {{~else~}}
+ {{definition.cloze.sentence}}
+ {{~/if~}}
+ {{~/if~}}
+{{/inline}}
+
+{{~> (lookup . "marker") ~}}`.trimStart()
}
];