« get me outta code hell

test: generateAlbumSecondaryNav (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-06-15 17:22:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-15 17:22:12 -0300
commitfc5c3f4e66660018e835ab0f3b664ef0d6abe2ef (patch)
treef076cdb5b3c16c255efd9481afdd41cba51c7a1c
parent470536c0ead771976e6b8771930eabb8030081c4 (diff)
test: generateAlbumSecondaryNav (snapshot)
-rw-r--r--tap-snapshots/test/snapshot/generateAlbumSecondaryNav.js.test.cjs33
-rw-r--r--test/snapshot/generateAlbumSecondaryNav.js55
2 files changed, 88 insertions, 0 deletions
diff --git a/tap-snapshots/test/snapshot/generateAlbumSecondaryNav.js.test.cjs b/tap-snapshots/test/snapshot/generateAlbumSecondaryNav.js.test.cjs
new file mode 100644
index 00000000..f84827ae
--- /dev/null
+++ b/tap-snapshots/test/snapshot/generateAlbumSecondaryNav.js.test.cjs
@@ -0,0 +1,33 @@
+/* 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/generateAlbumSecondaryNav.js TAP generateAlbumSecondaryNav (snapshot) > basic behavior, mode: album 1`] = `
+<nav id="secondary-nav" class="nav-links-groups">
+    <span>
+        <a href="group/vcg/">VCG</a>
+        (<a href="album/first/">Previous</a>, <a href="album/last/">Next</a>)
+    </span>
+    <span>
+        <a href="group/bepis/">Bepis</a>
+        (<a href="album/second/">Next</a>)
+    </span>
+</nav>
+`
+
+exports[`test/snapshot/generateAlbumSecondaryNav.js TAP generateAlbumSecondaryNav (snapshot) > basic behavior, mode: track 1`] = `
+<nav id="secondary-nav" class="nav-links-groups">
+    <a href="group/vcg/">VCG</a>
+    <a href="group/bepis/">Bepis</a>
+</nav>
+`
+
+exports[`test/snapshot/generateAlbumSecondaryNav.js TAP generateAlbumSecondaryNav (snapshot) > dateless album in mixed group 1`] = `
+<nav id="secondary-nav" class="nav-links-groups">
+    <a href="group/vcg/">VCG</a>
+    <a href="group/bepis/">Bepis</a>
+</nav>
+`
diff --git a/test/snapshot/generateAlbumSecondaryNav.js b/test/snapshot/generateAlbumSecondaryNav.js
new file mode 100644
index 00000000..180cb6e0
--- /dev/null
+++ b/test/snapshot/generateAlbumSecondaryNav.js
@@ -0,0 +1,55 @@
+import t from 'tap';
+import {testContentFunctions} from '../lib/content-function.js';
+
+testContentFunctions(t, 'generateAlbumSecondaryNav (snapshot)', async (t, evaluate) => {
+  await evaluate.load();
+
+  let album, group1, group2;
+
+  group1 = {name: 'VCG', directory: 'vcg'};
+  group2 = {name: 'Bepis', directory: 'bepis'};
+
+  album = {
+    date: new Date('2010-04-13'),
+    groups: [group1, group2],
+  };
+
+  group1.albums = [
+    {name: 'First', directory: 'first', date: new Date('2010-04-10')},
+    album,
+    {name: 'Last', directory: 'last', date: new Date('2010-06-12')},
+  ];
+
+  group2.albums = [
+    album,
+    {name: 'Second', directory: 'second', date: new Date('2011-04-13')},
+  ];
+
+  evaluate.snapshot('basic behavior, mode: album', {
+    name: 'generateAlbumSecondaryNav',
+    args: [album],
+    slots: {mode: 'album'},
+  });
+
+  evaluate.snapshot('basic behavior, mode: track', {
+    name: 'generateAlbumSecondaryNav',
+    args: [album],
+    slots: {mode: 'track'},
+  });
+
+  album = {
+    date: null,
+    groups: [group1, group2],
+  };
+
+  group1.albums = [
+    ...group1.albums,
+    album,
+  ];
+
+  evaluate.snapshot('dateless album in mixed group', {
+    name: 'generateAlbumSecondaryNav',
+    args: [album],
+    slots: {mode: 'album'},
+  });
+});