« get me outta code hell

test: Album.trackSections (unit) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-08 12:34:48 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-08 12:34:48 -0300
commitf4305e5ab0a64a648f39c647b817a4ba09848f11 (patch)
treea180266032e20c0569fc33f633e7102b2630b4f0 /test/unit/data
parent65260d7fc2790ece0c13820ba18bc821163f164e (diff)
test: Album.trackSections (unit)
Diffstat (limited to 'test/unit/data')
-rw-r--r--test/unit/data/things/album.js68
-rw-r--r--test/unit/data/things/track.js2
2 files changed, 69 insertions, 1 deletions
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index 63d787e5..3593074a 100644
--- a/test/unit/data/things/album.js
+++ b/test/unit/data/things/album.js
@@ -143,3 +143,71 @@ t.test(`Album.tracks`, t => {
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #4: filters out references without matches`);
 });
+
+t.test(`Album.trackSections`, t => {
+  t.plan(5);
+
+  const album = new Album();
+  const track1 = stubTrack('track1');
+  const track2 = stubTrack('track2');
+  const track3 = stubTrack('track3');
+  const track4 = stubTrack('track4');
+
+  linkAndBindWikiData({
+    albumData: [album],
+    trackData: [track1, track2, track3, track4],
+  });
+
+  album.trackSections = [
+    {tracks: ['track:track1', 'track:track2']},
+    {tracks: ['track:track3', 'track:track4']},
+  ];
+
+  t.match(album.trackSections, [
+    {tracks: [track1, track2]},
+    {tracks: [track3, track4]},
+  ], `Album.trackSections #1: exposes tracks`);
+
+  t.match(album.trackSections, [
+    {tracks: [track1, track2], startIndex: 0},
+    {tracks: [track3, track4], startIndex: 2},
+  ], `Album.trackSections #2: exposes startIndex`);
+
+  album.color = '#123456';
+
+  album.trackSections = [
+    {tracks: ['track:track1'], color: null},
+    {tracks: ['track:track2'], color: '#abcdef'},
+    {tracks: ['track:track3'], color: null},
+  ];
+
+  t.match(album.trackSections, [
+    {tracks: [track1], color: '#123456'},
+    {tracks: [track2], color: '#abcdef'},
+    {tracks: [track3], color: '#123456'},
+  ], `Album.trackSections #3: exposes color, inherited from album`);
+
+  album.trackSections = [
+    {tracks: ['track:track1'], dateOriginallyReleased: null},
+    {tracks: ['track:track2'], dateOriginallyReleased: new Date('2009-04-11')},
+    {tracks: ['track:track3'], dateOriginallyReleased: null},
+  ];
+
+  t.match(album.trackSections, [
+    {tracks: [track1], dateOriginallyReleased: null},
+    {tracks: [track2], dateOriginallyReleased: new Date('2009-04-11')},
+    {tracks: [track3], dateOriginallyReleased: null},
+  ], `Album.trackSections #4: exposes dateOriginallyReleased, if present`);
+
+  album.trackSections = [
+    {tracks: ['track:track1'], isDefaultTrackSection: true},
+    {tracks: ['track:track2'], isDefaultTrackSection: false},
+    {tracks: ['track:track3'], isDefaultTrackSection: null},
+  ];
+
+  t.match(album.trackSections, [
+    {tracks: [track1], isDefaultTrackSection: true},
+    {tracks: [track2], isDefaultTrackSection: false},
+    {tracks: [track3], isDefaultTrackSection: false},
+  ], `Album.trackSections #5: exposes isDefaultTrackSection, defaults to false`);
+});
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js
index 6597c2f9..8aecf789 100644
--- a/test/unit/data/things/track.js
+++ b/test/unit/data/things/track.js
@@ -383,7 +383,7 @@ t.test(`Track.hasUniqueCoverArt`, t => {
     `hasUniqueCoverArt #7: is false if track's coverArtistContribs resolve empty`);
 });
 
-t.only(`Track.originalReleaseTrack`, t => {
+t.test(`Track.originalReleaseTrack`, t => {
   t.plan(3);
 
   const {track: track1, album: album1} = stubTrackAndAlbum('track1');