« get me outta code hell

test: {Track,Album}.artTags (unit), expect tags only w/ cover art - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/things/album.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-13 14:24:55 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-13 14:28:34 -0400
commit4f99ea91531b212f8ae223fd4c4ad56fe262785c (patch)
treeb4e6a9c5cbc8591a10d7e3aebba036ffefb66976 /test/unit/data/things/album.js
parent96115bbd3a91d0bbe2cc5012614df6a231a82543 (diff)
test: {Track,Album}.artTags (unit), expect tags only w/ cover art
Diffstat (limited to 'test/unit/data/things/album.js')
-rw-r--r--test/unit/data/things/album.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index 5a1261a..46ea83b 100644
--- a/test/unit/data/things/album.js
+++ b/test/unit/data/things/album.js
@@ -5,10 +5,18 @@ import thingConstructors from '#things';
 
 const {
   Album,
+  ArtTag,
   Artist,
   Track,
 } = thingConstructors;
 
+function stubArtTag(tagName = `Test Art Tag`) {
+  const tag = new ArtTag();
+  tag.name = tagName;
+
+  return tag;
+}
+
 function stubArtistAndContribs() {
   const artist = new Artist();
   artist.name = `Test Artist`;
@@ -26,6 +34,34 @@ function stubTrack(directory = 'foo') {
   return track;
 }
 
+t.test(`Album.artTags`, t => {
+  t.plan(3);
+
+  const {artist, contribs} = stubArtistAndContribs();
+  const album = new Album();
+  const tag1 = stubArtTag(`Tag 1`);
+  const tag2 = stubArtTag(`Tag 2`);
+
+  const {XXX_decacheWikiData} = linkAndBindWikiData({
+    albumData: [album],
+    artistData: [artist],
+    artTagData: [tag1, tag2],
+  });
+
+  t.same(album.artTags, [],
+    `artTags #1: defaults to empty array`);
+
+  album.artTags = [`Tag 1`, `Tag 2`];
+
+  t.same(album.artTags, [],
+    `artTags #2: is empty if album doesn't have cover artists`);
+
+  album.coverArtistContribs = contribs;
+
+  t.same(album.artTags, [tag1, tag2],
+    `artTags #3: resolves if album has cover artists`);
+});
+
 t.test(`Album.bannerDimensions`, t => {
   t.plan(4);