« get me outta code hell

test: generateAlbumReleaseInfo (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-13 18:36:53 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-13 18:37:05 -0300
commit5111e6be757ca89d27876ddb68de4b916b23bfe1 (patch)
tree51e3d59dc06926c28ff152fc8780d92517bded0e
parentafdc1e4bee3eba30a83ec3f71617573331d98169 (diff)
test: generateAlbumReleaseInfo (snapshot)
-rw-r--r--tap-snapshots/test/snapshot/generateAlbumReleaseInfo.js.test.cjs42
-rw-r--r--tap-snapshots/test/snapshot/generateTrackReleaseInfo.js.test.cjs8
-rw-r--r--test/snapshot/generateAlbumReleaseInfo.js74
-rw-r--r--test/snapshot/generateTrackReleaseInfo.js2
4 files changed, 121 insertions, 5 deletions
diff --git a/tap-snapshots/test/snapshot/generateAlbumReleaseInfo.js.test.cjs b/tap-snapshots/test/snapshot/generateAlbumReleaseInfo.js.test.cjs
new file mode 100644
index 00000000..769018a9
--- /dev/null
+++ b/tap-snapshots/test/snapshot/generateAlbumReleaseInfo.js.test.cjs
@@ -0,0 +1,42 @@
+/* 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/generateAlbumReleaseInfo.js TAP generateAlbumReleaseInfo (snapshot) > URLs only 1`] = `
+<p>Listen on <a href="https://homestuck.bandcamp.com/foo" class="nowrap">Bandcamp</a> or <a href="https://soundcloud.com/bar" class="nowrap">SoundCloud</a>.</p>
+`
+
+exports[`test/snapshot/generateAlbumReleaseInfo.js TAP generateAlbumReleaseInfo (snapshot) > basic behavior 1`] = `
+<p>
+    By <a href="artist/toby-fox/">Toby Fox</a> (music probably) and <a href="artist/tensei/">Tensei</a> (hot jams) (<span class="icons"><a href="https://tenseimusic.bandcamp.com/" class="icon">
+            <svg>
+                <title>Bandcamp</title>
+                <use href="static/icons.svg#icon-bandcamp"></use>
+            </svg>
+        </a></span>).
+    <br>
+    Cover art by <a href="artist/hb/">Hanni Brosh</a>.
+    <br>
+    Wallpaper art by <a href="artist/hb/">Hanni Brosh</a> and <a href="artist/niklink/">Niklink</a> (edits).
+    <br>
+    Banner art by <a href="artist/hb/">Hanni Brosh</a> and <a href="artist/niklink/">Niklink</a> (edits).
+    <br>
+    Released 3/14/2011.
+    <br>
+    Art released 4/1/1991.
+    <br>
+    Duration: ~10:25.
+</p>
+<p>Listen on <a href="https://homestuck.bandcamp.com/album/alterniabound-with-alternia" class="nowrap">Bandcamp</a>, <a href="https://www.youtube.com/playlist?list=PLnVpmehyaOFZWO9QOZmD6A3TIK0wZ6xE2" class="nowrap">YouTube (playlist)</a>, or <a href="https://www.youtube.com/watch?v=HO5V2uogkYc" class="nowrap">YouTube (full album)</a>.</p>
+`
+
+exports[`test/snapshot/generateAlbumReleaseInfo.js TAP generateAlbumReleaseInfo (snapshot) > equal cover art date 1`] = `
+<p>Released 4/12/2020.</p>
+`
+
+exports[`test/snapshot/generateAlbumReleaseInfo.js TAP generateAlbumReleaseInfo (snapshot) > reduced details 1`] = `
+
+`
diff --git a/tap-snapshots/test/snapshot/generateTrackReleaseInfo.js.test.cjs b/tap-snapshots/test/snapshot/generateTrackReleaseInfo.js.test.cjs
index b72680ae..a5f9e971 100644
--- a/tap-snapshots/test/snapshot/generateTrackReleaseInfo.js.test.cjs
+++ b/tap-snapshots/test/snapshot/generateTrackReleaseInfo.js.test.cjs
@@ -5,7 +5,7 @@
  * Make sure to inspect the output below.  Do not ignore changes!
  */
 'use strict'
-exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > basic behavior 1`] = `
+exports[`test/snapshot/generateTrackReleaseInfo.js TAP generateTrackReleaseInfo (snapshot) > basic behavior 1`] = `
 <p>
     By <a href="artist/toby-fox/">Toby Fox</a>.
     <br>
@@ -16,12 +16,12 @@ exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > b
 <p>Listen on <a href="https://soundcloud.com/foo" class="nowrap">SoundCloud</a> or <a href="https://youtube.com/watch?v=bar" class="nowrap">YouTube</a>.</p>
 `
 
-exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > cover artist contribs, non-unique 1`] = `
+exports[`test/snapshot/generateTrackReleaseInfo.js TAP generateTrackReleaseInfo (snapshot) > cover artist contribs, non-unique 1`] = `
 <p>By <a href="artist/toby-fox/">Toby Fox</a>.</p>
 <p>This wiki doesn&apos;t have any listening links for <i>Suspicious Track</i>.</p>
 `
 
-exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > cover artist contribs, unique 1`] = `
+exports[`test/snapshot/generateTrackReleaseInfo.js TAP generateTrackReleaseInfo (snapshot) > cover artist contribs, unique 1`] = `
 <p>
     By <a href="artist/toby-fox/">Toby Fox</a>.
     <br>
@@ -30,7 +30,7 @@ exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > c
 <p>This wiki doesn&apos;t have any listening links for <i>Suspicious Track</i>.</p>
 `
 
-exports[`test/snapshot/generateTrackReleaseInfo.js TAP linkArtist (snapshot) > reduced details 1`] = `
+exports[`test/snapshot/generateTrackReleaseInfo.js TAP generateTrackReleaseInfo (snapshot) > reduced details 1`] = `
 <p>By <a href="artist/toby-fox/">Toby Fox</a>.</p>
 <p>This wiki doesn&apos;t have any listening links for <i>Suspicious Track</i>.</p>
 `
diff --git a/test/snapshot/generateAlbumReleaseInfo.js b/test/snapshot/generateAlbumReleaseInfo.js
new file mode 100644
index 00000000..cbee5eb7
--- /dev/null
+++ b/test/snapshot/generateAlbumReleaseInfo.js
@@ -0,0 +1,74 @@
+import t from 'tap';
+import {testContentFunctions} from '../lib/content-function.js';
+
+testContentFunctions(t, 'generateAlbumReleaseInfo (snapshot)', async (t, evaluate) => {
+  await evaluate.load();
+
+  evaluate.snapshot('basic behavior', {
+    name: 'generateAlbumReleaseInfo',
+    args: [{
+      artistContribs: [
+        {who: {name: 'Toby Fox', directory: 'toby-fox'}, what: 'music probably'},
+        {who: {name: 'Tensei', directory: 'tensei', urls: ['https://tenseimusic.bandcamp.com/']}, what: 'hot jams'},
+      ],
+
+      coverArtistContribs: [
+        {who: {name: 'Hanni Brosh', directory: 'hb'}, what: null},
+      ],
+
+      wallpaperArtistContribs: [
+        {who: {name: 'Hanni Brosh', directory: 'hb'}, what: null},
+        {who: {name: 'Niklink', directory: 'niklink'}, what: 'edits'},
+      ],
+
+      bannerArtistContribs: [
+        {who: {name: 'Hanni Brosh', directory: 'hb'}, what: null},
+        {who: {name: 'Niklink', directory: 'niklink'}, what: 'edits'},
+      ],
+
+      name: 'AlterniaBound',
+      date: new Date('March 14, 2011'),
+      coverArtDate: new Date('April 1, 1991'),
+      urls: [
+        'https://homestuck.bandcamp.com/album/alterniabound-with-alternia',
+        'https://www.youtube.com/playlist?list=PLnVpmehyaOFZWO9QOZmD6A3TIK0wZ6xE2',
+        'https://www.youtube.com/watch?v=HO5V2uogkYc',
+      ],
+
+      tracks: [{duration: 253}, {duration: 372}],
+    }],
+  });
+
+  const sparse = {
+    artistContribs: [],
+    coverArtistContribs: [],
+    wallpaperArtistContribs: [],
+    bannerArtistContribs: [],
+
+    name: 'Suspicious Album',
+    urls: [],
+    tracks: [],
+  };
+
+  evaluate.snapshot('reduced details', {
+    name: 'generateAlbumReleaseInfo',
+    args: [sparse],
+  });
+
+  evaluate.snapshot('URLs only', {
+    name: 'generateAlbumReleaseInfo',
+    args: [{
+      ...sparse,
+      urls: ['https://homestuck.bandcamp.com/foo', 'https://soundcloud.com/bar'],
+    }],
+  });
+
+  evaluate.snapshot('equal cover art date', {
+    name: 'generateAlbumReleaseInfo',
+    args: [{
+      ...sparse,
+      date: new Date('2020-04-13'),
+      coverArtDate: new Date('2020-04-13'),
+    }],
+  });
+});
diff --git a/test/snapshot/generateTrackReleaseInfo.js b/test/snapshot/generateTrackReleaseInfo.js
index c9c40684..dd7ebd8e 100644
--- a/test/snapshot/generateTrackReleaseInfo.js
+++ b/test/snapshot/generateTrackReleaseInfo.js
@@ -1,7 +1,7 @@
 import t from 'tap';
 import {testContentFunctions} from '../lib/content-function.js';
 
-testContentFunctions(t, 'linkArtist (snapshot)', async (t, evaluate) => {
+testContentFunctions(t, 'generateTrackReleaseInfo (snapshot)', async (t, evaluate) => {
   await evaluate.load();
 
   const artistContribs = [{who: {name: 'Toby Fox', directory: 'toby-fox'}, what: null}];