« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/data/things/album.js36
-rw-r--r--test/unit/data/things/track.js58
2 files changed, 94 insertions, 0 deletions
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index 5a1261a4..46ea83b0 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);
 
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js
index 57bd4253..0abb37cf 100644
--- a/test/unit/data/things/track.js
+++ b/test/unit/data/things/track.js
@@ -6,6 +6,7 @@ import thingConstructors from '#things';
 
 const {
   Album,
+  ArtTag,
   Artist,
   Flash,
   FlashAct,
@@ -52,6 +53,13 @@ function stubArtistAndContribs(artistName = `Test Artist`) {
   return {artist, contribs, badContribs};
 }
 
+function stubArtTag(tagName = `Test Art Tag`) {
+  const tag = new ArtTag();
+  tag.name = tagName;
+
+  return tag;
+}
+
 function stubFlashAndAct(directory = 'zam') {
   const flash = new Flash();
   flash.directory = directory;
@@ -115,6 +123,56 @@ t.test(`Track.album`, t => {
     `album #6: is null when album's trackSections don't match track`);
 });
 
+t.test(`Track.artTags`, t => {
+  t.plan(6);
+
+  const {track, album} = stubTrackAndAlbum();
+  const {artist, contribs} = stubArtistAndContribs();
+  const tag1 = stubArtTag(`Tag 1`);
+  const tag2 = stubArtTag(`Tag 2`);
+
+  const {XXX_decacheWikiData} = linkAndBindWikiData({
+    albumData: [album],
+    artistData: [artist],
+    artTagData: [tag1, tag2],
+    trackData: [track],
+  });
+
+  t.same(track.artTags, [],
+    `artTags #1: defaults to empty array`);
+
+  track.artTags = [`Tag 1`, `Tag 2`];
+
+  t.same(track.artTags, [],
+    `artTags #2: is empty if track doesn't have cover artists`);
+
+  track.coverArtistContribs = contribs;
+
+  t.same(track.artTags, [tag1, tag2],
+    `artTags #3: resolves if track has cover artists`);
+
+  track.coverArtistContribs = null;
+  album.trackCoverArtistContribs = contribs;
+
+  XXX_decacheWikiData();
+
+  t.same(track.artTags, [tag1, tag2],
+    `artTags #4: resolves if track inherits cover artists`);
+
+  track.disableUniqueCoverArt = true;
+
+  t.same(track.artTags, [],
+    `artTags #5: is empty if track disables unique cover artwork`);
+
+  album.coverArtistContribs = contribs;
+  album.artTags = [`Tag 2`];
+
+  XXX_decacheWikiData();
+
+  t.notSame(track.artTags, [tag2],
+    `artTags #6: doesn't inherit from album's art tags`);
+});
+
 t.test(`Track.artistContribs`, t => {
   t.plan(4);