« get me outta code hell

test: update track section unit tests, don't be magically easy - 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:
author(quasar) nebula <qznebula@protonmail.com>2024-06-01 00:03:22 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-01 00:03:52 -0300
commit401236648e1efe907798dd4e2d368f1fbc773b62 (patch)
treea753a0efc80c193ba117b9ccebe282fdb214d6dc /test/unit
parenta9384aaa1d5951dda497749776c872b3aa2a83d1 (diff)
test: update track section unit tests, don't be magically easy
Most notably drops automatically setting ownTrackData.
Hilariously, this doesn't break any tests (presumably because
they were generally updated to handle a newer - albeit not the
newest - track section format).
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/data/things/album.js40
-rw-r--r--test/unit/data/things/art-tag.js3
-rw-r--r--test/unit/data/things/track.js22
3 files changed, 47 insertions, 18 deletions
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index d28ab709..06265b09 100644
--- a/test/unit/data/things/album.js
+++ b/test/unit/data/things/album.js
@@ -262,6 +262,13 @@ t.test(`Album.tracks`, t => {
   const section6 = stubTrackSection(album, [], 'section6');
   const sections = [section1, section2, section3, section4, section5, section6];
 
+  const section1_ref = `unqualified-track-section:section1`;
+  const section2_ref = `unqualified-track-section:section2`;
+  const section3_ref = `unqualified-track-section:section3`;
+  const section4_ref = `unqualified-track-section:section4`;
+  const section5_ref = `unqualified-track-section:section5`;
+  const section6_ref = `unqualified-track-section:section6`;
+
   for (const track of tracks) {
     track.albumData = [album];
   }
@@ -276,7 +283,8 @@ t.test(`Album.tracks`, t => {
   section1.tracks = ['track:track1', 'track:track2', 'track:track3'];
   section1.ownTrackData = [track1, track2, track3];
 
-  album.trackSections = [section1];
+  album.trackSections = [section1_ref];
+  album.ownTrackSectionData = [section1];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #2: pulls tracks from one track section`);
@@ -287,7 +295,8 @@ t.test(`Album.tracks`, t => {
   section1.ownTrackData = [track1];
   section2.ownTrackData = [track2, track3];
 
-  album.trackSections = [section1, section2];
+  album.trackSections = [section1_ref, section2_ref];
+  album.ownTrackSectionData = [section1, section2];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #3: pulls tracks from multiple track sections`);
@@ -302,7 +311,8 @@ t.test(`Album.tracks`, t => {
   section3.ownTrackData = [];
   section4.ownTrackData = [track3];
 
-  album.trackSections = [section1, section2, section3, section4];
+  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref];
+  album.ownTrackSectionData = [section1, section2, section3, section4];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #4: filters out references without matches`);
@@ -321,7 +331,8 @@ t.test(`Album.tracks`, t => {
   section5.ownTrackData = [];
   section6.ownTrackData = [track3];
 
-  album.trackSections = [section1, section2, section3, section4, section5, section6];
+  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref, section5_ref, section6_ref];
+  album.ownTrackSectionData = [section1, section2, section3, section4, section5, section6];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #5: skips empty track sections`);
@@ -345,6 +356,12 @@ t.test(`Album.trackSections`, t => {
   const section5 = stubTrackSection(album, [], 'section5');
   const sections = [section1, section2, section3, section4, section5];
 
+  const section1_ref = `unqualified-track-section:section1`;
+  const section2_ref = `unqualified-track-section:section2`;
+  const section3_ref = `unqualified-track-section:section3`;
+  const section4_ref = `unqualified-track-section:section4`;
+  const section5_ref = `unqualified-track-section:section5`;
+
   for (const track of tracks) {
     track.albumData = [album];
   }
@@ -355,7 +372,8 @@ t.test(`Album.trackSections`, t => {
   section1.ownTrackData = [track1, track2];
   section2.ownTrackData = [track3, track4];
 
-  album.trackSections = [section1, section2];
+  album.trackSections = [section1_ref, section2_ref];
+  album.ownTrackSectionData = [section1, section2];
 
   t.match(album.trackSections, [
     {tracks: [track1, track2]},
@@ -378,7 +396,8 @@ t.test(`Album.trackSections`, t => {
   section1.name = 'First section';
   section2.name = 'Second section';
 
-  album.trackSections = [section1, section2, section3];
+  album.trackSections = [section1_ref, section2_ref, section3_ref];
+  album.ownTrackSectionData = [section1, section2, section3];
 
   t.match(album.trackSections, [
     {name: 'First section', tracks: [track1]},
@@ -392,7 +411,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1, section2, section3];
+  album.trackSections = [section1_ref, section2_ref, section3_ref];
 
   t.match(album.trackSections, [
     {tracks: [track1], color: '#123456'},
@@ -404,7 +423,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1, section2, section3];
+  album.trackSections = [section1_ref, section2_ref, section3_ref];
 
   t.match(album.trackSections, [
     {tracks: [track1], dateOriginallyReleased: null},
@@ -417,7 +436,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1, section2, section3];
+  album.trackSections = [section1_ref, section2_ref, section3_ref];
 
   t.match(album.trackSections, [
     {tracks: [track1], isDefaultTrackSection: true},
@@ -443,7 +462,8 @@ t.test(`Album.trackSections`, t => {
   section4.color = '#556677';
   section5.color = '#778899';
 
-  album.trackSections = [section1, section2, section3, section4, section5];
+  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref, section5_ref];
+  album.ownTrackSectionData = [section1, section2, section3, section4, section5];
 
   t.match(album.trackSections, [
     {tracks: [track1, track2], color: '#112233'},
diff --git a/test/unit/data/things/art-tag.js b/test/unit/data/things/art-tag.js
index 427b357b..cf2135c6 100644
--- a/test/unit/data/things/art-tag.js
+++ b/test/unit/data/things/art-tag.js
@@ -16,7 +16,8 @@ function stubAlbum(tracks, directory = 'bar') {
   album.directory = directory;
 
   const trackSection = stubTrackSection(album, tracks);
-  album.trackSections = [trackSection];
+  album.trackSections = [`unqualified-track-section:${trackSection.unqualifiedDirectory}`];
+  album.ownTrackSectionData = [trackSection];
 
   return album;
 }
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js
index 644d21ce..c6695b6f 100644
--- a/test/unit/data/things/track.js
+++ b/test/unit/data/things/track.js
@@ -19,7 +19,8 @@ function stubAlbum(tracks, directory = 'bar') {
   album.directory = directory;
 
   const trackSection = stubTrackSection(album, tracks);
-  album.trackSections = [trackSection];
+  album.trackSections = [`unqualified-track-section:${trackSection.unqualifiedDirectory}`];
+  album.ownTrackSectionData = [trackSection];
 
   return album;
 }
@@ -93,6 +94,10 @@ t.test(`Track.album`, t => {
   const album2 = new Album();
   const section1 = new TrackSection();
   const section2 = new TrackSection();
+  section1.unqualifiedDirectory = 'section1';
+  section2.unqualifiedDirectory = 'section2';
+  const section1_ref = `unqualified-track-section:section1`;
+  const section2_ref = `unqualified-track-section:section2`;
 
   t.equal(track1.album, null,
     `album #1: defaults to null`);
@@ -105,8 +110,10 @@ t.test(`Track.album`, t => {
   section2.ownAlbumData = [album2];
   section1.tracks = ['track:track1'];
   section2.tracks = ['track:track2'];
-  album1.trackSections = [section1];
-  album2.trackSections = [section2];
+  album1.trackSections = [section1_ref];
+  album2.trackSections = [section2_ref];
+  album1.ownTrackSectionData = [section1];
+  album2.ownTrackSectionData = [section2];
 
   t.equal(track1.album, album1,
     `album #2: is album when album's trackSections matches track`);
@@ -125,7 +132,7 @@ t.test(`Track.album`, t => {
 
   // XXX_decacheWikiData
   album1.trackSections = [];
-  album1.trackSections = [section1];
+  album1.trackSections = [section1_ref];
   track1.albumData = [];
   track1.albumData = [album2, album1];
 
@@ -137,7 +144,7 @@ t.test(`Track.album`, t => {
 
   // XXX_decacheWikiData
   album1.trackSections = [];
-  album1.trackSections = [section1];
+  album1.trackSections = [section1_ref];
   track1.albumData = [];
   track1.albumData = [album2, album1];
 
@@ -308,12 +315,13 @@ t.test(`Track.color`, t => {
   t.equal(track.color, null,
     `color #1: defaults to null`);
 
-  const section = stubTrackSection(album, [track]);
+  const section = stubTrackSection(album, [track], 'section');
 
   album.color = '#abcdef';
   section.color = '#beeeef';
 
-  album.trackSections = [section];
+  album.trackSections = [`unqualified-track-section:section`];
+  album.ownTrackSectionData = [section];
 
   XXX_decacheWikiData();