diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-04-05 16:06:52 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-04-05 16:06:52 -0300 |
commit | cea250920bdbe12e1d87469ee9070211610884a4 (patch) | |
tree | 0d60d7b272ce8f5d65707224730b00456e31f0c8 | |
parent | 17f1220718f0e736723108042fc00cd5cb90070d (diff) |
test: generateAdditionalFilesShortcut (snapshot)
3 files changed, 56 insertions, 0 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesShortcut.js b/src/content/dependencies/generateAdditionalFilesShortcut.js index dd097e28..7dfe07b3 100644 --- a/src/content/dependencies/generateAdditionalFilesShortcut.js +++ b/src/content/dependencies/generateAdditionalFilesShortcut.js @@ -1,3 +1,5 @@ +import {empty} from '../../util/sugar.js'; + export default { extraDependencies: [ 'html', @@ -14,6 +16,10 @@ export default { html, language, }) { + if (empty(data.titles)) { + return html.blank(); + } + return language.$('releaseInfo.additionalFiles.shortcut', { anchorLink: html.tag('a', diff --git a/tap-snapshots/test/snapshot/generateAdditionalFilesShortcut.js.test.cjs b/tap-snapshots/test/snapshot/generateAdditionalFilesShortcut.js.test.cjs new file mode 100644 index 00000000..74b5f47f --- /dev/null +++ b/tap-snapshots/test/snapshot/generateAdditionalFilesShortcut.js.test.cjs @@ -0,0 +1,14 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/snapshot/generateAdditionalFilesShortcut.js TAP generateAdditionalFilesShortcut (snapshot) > basic behavior 1`] = ` +<a href="#additional-files">Additional files:</a> SBURB Wallpaper, Alternate Covers +` + +exports[`test/snapshot/generateAdditionalFilesShortcut.js TAP generateAdditionalFilesShortcut (snapshot) > no additional files 1`] = ` + +` diff --git a/test/snapshot/generateAdditionalFilesShortcut.js b/test/snapshot/generateAdditionalFilesShortcut.js new file mode 100644 index 00000000..0ca777b4 --- /dev/null +++ b/test/snapshot/generateAdditionalFilesShortcut.js @@ -0,0 +1,36 @@ +import t from 'tap'; +import {testContentFunctions} from '../lib/content-function.js'; + +testContentFunctions(t, 'generateAdditionalFilesShortcut (snapshot)', async (t, evaluate) => { + await evaluate.load(); + + evaluate.snapshot('no additional files', { + name: 'generateAdditionalFilesShortcut', + args: [[]], + }); + + evaluate.snapshot('basic behavior', { + name: 'generateAdditionalFilesShortcut', + args: [ + [ + { + title: 'SBURB Wallpaper', + files: [ + 'sburbwp_1280x1024.jpg', + 'sburbwp_1440x900.jpg', + 'sburbwp_1920x1080.jpg', + ], + }, + { + title: 'Alternate Covers', + description: 'This is just an example description.', + files: [ + 'Homestuck_Vol4_alt1.jpg', + 'Homestuck_Vol4_alt2.jpg', + 'Homestuck_Vol4_alt3.jpg', + ], + }, + ], + ], + }); +}); |