« get me outta code hell

test: generateAdditionalFilesList (snapshot) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-04-05 16:32:06 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-05 16:32:06 -0300
commit8afc6ec1b57d81d654c56956978ac01ed145c301 (patch)
tree4e296eb3aa7f8ab3d4e7cdb64e15d8d1988a14e6
parent6e7d540f2daf84399f34fc923f7f08cc15af3525 (diff)
test: generateAdditionalFilesList (snapshot)
-rw-r--r--tap-snapshots/test/snapshot/generateAdditionalFilesList.js.test.cjs29
-rw-r--r--test/snapshot/generateAdditionalFilesList.js63
2 files changed, 92 insertions, 0 deletions
diff --git a/tap-snapshots/test/snapshot/generateAdditionalFilesList.js.test.cjs b/tap-snapshots/test/snapshot/generateAdditionalFilesList.js.test.cjs
new file mode 100644
index 00000000..5ca63482
--- /dev/null
+++ b/tap-snapshots/test/snapshot/generateAdditionalFilesList.js.test.cjs
@@ -0,0 +1,29 @@
+/* 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/generateAdditionalFilesList.js TAP generateAdditionalFilesList (snapshot) > basic behavior 1`] = `
+<dl>
+    <dt>SBURB Wallpaper</dt>
+    <dd>
+        <ul>
+            <li>link to 1280x1024 (2.5 kB)</li>
+            <li>link to 1440x900</li>
+        </ul>
+    </dd>
+    <dt>Alternate Covers: This is just an example description.</dt>
+    <dd>
+        <ul>
+            <li>link to alt1 (1.2 MB)</li>
+            <li>link to alt3 (1.2 MB)</li>
+        </ul>
+    </dd>
+</dl>
+`
+
+exports[`test/snapshot/generateAdditionalFilesList.js TAP generateAdditionalFilesList (snapshot) > no additional files 1`] = `
+
+`
diff --git a/test/snapshot/generateAdditionalFilesList.js b/test/snapshot/generateAdditionalFilesList.js
new file mode 100644
index 00000000..ce876d8d
--- /dev/null
+++ b/test/snapshot/generateAdditionalFilesList.js
@@ -0,0 +1,63 @@
+import t from 'tap';
+import {testContentFunctions} from '../lib/content-function.js';
+
+testContentFunctions(t, 'generateAdditionalFilesList (snapshot)', async (t, evaluate) => {
+  await evaluate.load();
+
+  evaluate.snapshot('no additional files', {
+    name: 'generateAdditionalFilesList',
+    args: [[]],
+  });
+
+  evaluate.snapshot('basic behavior', {
+    name: 'generateAdditionalFilesList',
+    args: [
+      [
+        {
+          title: 'SBURB Wallpaper',
+          files: [
+            'sburbwp_1280x1024.jpg',
+            'sburbwp_1440x900.jpg',
+            'sburbwp_1920x1080.jpg',
+          ],
+        },
+        {
+          title: 'Fake Section',
+          description: 'Ooo, what happens if there are NO file links provided?',
+          files: [
+            'oops.mp3',
+            'Internet Explorer.gif',
+            'daisy.mp3',
+          ],
+        },
+        {
+          title: 'Alternate Covers',
+          description: 'This is just an example description.',
+          files: [
+            'Homestuck_Vol4_alt1.jpg',
+            'Homestuck_Vol4_alt2.jpg',
+            'Homestuck_Vol4_alt3.jpg',
+          ],
+        },
+      ],
+    ],
+    postprocess: template => template
+      .slot('additionalFileLinks', {
+        'sburbwp_1280x1024.jpg': 'link to 1280x1024',
+        'sburbwp_1440x900.jpg': 'link to 1440x900',
+        'sburbwp_1920x1080.jpg': null,
+        'Homestuck_Vol4_alt1.jpg': 'link to alt1',
+        'Homestuck_Vol4_alt2.jpg': null,
+        'Homestuck_Vol4_alt3.jpg': 'link to alt3',
+      })
+      .slot('additionalFileSizes', {
+        'sburbwp_1280x1024.jpg': 2500,
+        'sburbwp_1440x900.jpg': null,
+        'sburbwp_1920x1080.jpg': null,
+        'Internet Explorer.gif': 1,
+        'Homestuck_Vol4_alt1.jpg': 1234567,
+        'Homestuck_Vol4_alt2.jpg': 1234567,
+        'Homestuck_Vol4_alt3.jpg': 1234567,
+      }),
+  });
+});