« 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/data
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/data')
-rw-r--r--test/unit/data/things/album.js88
-rw-r--r--test/unit/data/things/art-tag.js5
-rw-r--r--test/unit/data/things/track.js22
3 files changed, 32 insertions, 83 deletions
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index e9c0d700..8be9d9ee 100644
--- a/test/unit/data/things/album.js
+++ b/test/unit/data/things/album.js
@@ -38,9 +38,8 @@ function stubTrack(directory = 'foo') {
 function stubTrackSection(album, tracks, directory = 'baz') {
   const trackSection = new TrackSection();
   trackSection.unqualifiedDirectory = directory;
-  trackSection.tracks = tracks.map(t => Thing.getReference(t));
-  trackSection.ownTrackData = tracks;
-  trackSection.ownAlbumData = [album];
+  trackSection.tracks = tracks;
+  trackSection.albumData = [album];
   return trackSection;
 }
 
@@ -244,7 +243,7 @@ t.test(`Album.coverArtFileExtension`, t => {
 });
 
 t.test(`Album.tracks`, t => {
-  t.plan(5);
+  t.plan(4);
 
   const album = new Album();
   album.directory = 'foo';
@@ -267,64 +266,38 @@ t.test(`Album.tracks`, t => {
   }
 
   for (const section of sections) {
-    section.ownAlbumData = [album];
+    section.albumData = [album];
   }
 
   t.same(album.tracks, [],
     `Album.tracks #1: defaults to empty array`);
 
-  section1.tracks = ['track:track1', 'track:track2', 'track:track3'];
-  section1.ownTrackData = [track1, track2, track3];
+  section1.tracks = [track1, track2, track3];
 
   album.trackSections = [section1];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #2: pulls tracks from one track section`);
 
-  section1.tracks = ['track:track1'];
-  section2.tracks = ['track:track2', 'track:track3'];
-
-  section1.ownTrackData = [track1];
-  section2.ownTrackData = [track2, track3];
+  section1.tracks = [track1];
+  section2.tracks = [track2, track3];
 
   album.trackSections = [section1, section2];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #3: pulls tracks from multiple track sections`);
 
-  section1.tracks = ['track:track1', 'track:does-not-exist'];
-  section2.tracks = ['track:this-one-neither', 'track:track2'];
-  section3.tracks = ['track:effectively-empty-section'];
-  section4.tracks = ['track:track3'];
-
-  section1.ownTrackData = [track1];
-  section2.ownTrackData = [track2];
-  section3.ownTrackData = [];
-  section4.ownTrackData = [track3];
-
-  album.trackSections = [section1, section2, section3, section4];
-
-  t.same(album.tracks, [track1, track2, track3],
-    `Album.tracks #4: filters out references without matches`);
-
-  section1.tracks = ['track:track1'];
+  section1.tracks = [track1];
   section2.tracks = [];
-  section3.tracks = ['track:track2'];
+  section3.tracks = [track2];
   section4.tracks = [];
   section5.tracks = [];
-  section6.tracks = ['track:track3'];
-
-  section1.ownTrackData = [track1];
-  section2.ownTrackData = [];
-  section3.ownTrackData = [track2];
-  section4.ownTrackData = [];
-  section5.ownTrackData = [];
-  section6.ownTrackData = [track3];
+  section6.tracks = [track3];
 
   album.trackSections = [section1, section2, section3, section4, section5, section6];
 
   t.same(album.tracks, [track1, track2, track3],
-    `Album.tracks #5: skips empty track sections`);
+    `Album.tracks #4: skips empty track sections`);
 });
 
 t.test(`Album.trackSections`, t => {
@@ -345,21 +318,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];
   }
 
-  section1.tracks = ['track:track1', 'track:track2'];
-  section2.tracks = ['track:track3', 'track:track4'];
-
-  section1.ownTrackData = [track1, track2];
-  section2.ownTrackData = [track3, track4];
+  section1.tracks = [track1, track2];
+  section2.tracks = [track3, track4];
 
   album.trackSections = [section1, section2];
 
@@ -373,13 +337,9 @@ t.test(`Album.trackSections`, t => {
     {tracks: [track3, track4], startIndex: 2},
   ], `Album.trackSections #2: exposes startIndex`);
 
-  section1.tracks = ['track:track1'];
-  section2.tracks = ['track:track2'];
-  section3.tracks = ['track:track3'];
-
-  section1.ownTrackData = [track1];
-  section2.ownTrackData = [track2];
-  section3.ownTrackData = [track3];
+  section1.tracks = [track1];
+  section2.tracks = [track2];
+  section3.tracks = [track3];
 
   section1.name = 'First section';
   section2.name = 'Second section';
@@ -431,17 +391,11 @@ t.test(`Album.trackSections`, t => {
     {tracks: [track3], isDefaultTrackSection: false},
   ], `Album.trackSections #6: exposes isDefaultTrackSection, defaults to false`);
 
-  section1.tracks = ['track:track1', 'track:track2', 'track:snooping'];
-  section2.tracks = ['track:track3', 'track:as-usual'];
+  section1.tracks = [track1, track2];
+  section2.tracks = [track3];
   section3.tracks = [];
-  section4.tracks = ['track:icy', 'track:chilly', 'track:frigid'];
-  section5.tracks = ['track:track4'];
-
-  section1.ownTrackData = [track1, track2];
-  section2.ownTrackData = [track3];
-  section3.ownTrackData = [];
-  section4.ownTrackData = [];
-  section5.ownTrackData = [track4];
+  section4.tracks = [];
+  section5.tracks = [track4];
 
   section1.color = '#112233';
   section2.color = '#334455';
@@ -457,7 +411,7 @@ t.test(`Album.trackSections`, t => {
     {tracks: [],               color: '#bbbbba'},
     {tracks: [],               color: '#556677'},
     {tracks: [track4],         color: '#778899'},
-  ], `Album.trackSections #7: filters out references without matches, keeps empty sections`);
+  ], `Album.trackSections #7: keeps empty sections`);
 });
 
 t.test(`Album.wallpaperFileExtension`, t => {
diff --git a/test/unit/data/things/art-tag.js b/test/unit/data/things/art-tag.js
index cf2135c6..e4879326 100644
--- a/test/unit/data/things/art-tag.js
+++ b/test/unit/data/things/art-tag.js
@@ -25,9 +25,8 @@ function stubAlbum(tracks, directory = 'bar') {
 function stubTrackSection(album, tracks, directory = 'baz') {
   const trackSection = new TrackSection();
   trackSection.unqualifiedDirectory = directory;
-  trackSection.tracks = tracks.map(t => Thing.getReference(t));
-  trackSection.ownTrackData = tracks;
-  trackSection.ownAlbumData = [album];
+  trackSection.tracks = tracks;
+  trackSection.albumData = [album];
   return trackSection;
 }
 
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js
index e27fb449..3fe4b4de 100644
--- a/test/unit/data/things/track.js
+++ b/test/unit/data/things/track.js
@@ -27,9 +27,8 @@ function stubAlbum(tracks, directory = 'bar') {
 function stubTrackSection(album, tracks, directory = 'baz') {
   const trackSection = new TrackSection();
   trackSection.unqualifiedDirectory = directory;
-  trackSection.tracks = tracks.map(t => Thing.getReference(t));
-  trackSection.ownTrackData = tracks;
-  trackSection.ownAlbumData = [album];
+  trackSection.tracks = tracks;
+  trackSection.albumData = [album];
   return trackSection;
 }
 
@@ -101,12 +100,10 @@ t.test(`Track.album`, t => {
 
   track1.albumData = [album1, album2];
   track2.albumData = [album1, album2];
-  section1.ownTrackData = [track1];
-  section2.ownTrackData = [track2];
-  section1.ownAlbumData = [album1];
-  section2.ownAlbumData = [album2];
-  section1.tracks = ['track:track1'];
-  section2.tracks = ['track:track2'];
+  section1.tracks = [track1];
+  section2.tracks = [track2];
+  section1.albumData = [album1];
+  section2.albumData = [album2];
   album1.trackSections = [section1];
   album2.trackSections = [section2];
 
@@ -123,7 +120,7 @@ t.test(`Track.album`, t => {
   t.equal(track1.album, null,
     `album #4: is null when track missing albumData`);
 
-  section1.ownTrackData = [];
+  section1.tracks = [];
 
   // XXX_decacheWikiData
   album1.trackSections = [];
@@ -132,10 +129,9 @@ t.test(`Track.album`, t => {
   track1.albumData = [album2, album1];
 
   t.equal(track1.album, null,
-    `album #5: is null when album track section missing ownTrackData`);
+    `album #5: is null when album track section missing tracks`);
 
-  section1.ownTrackData = [track2];
-  section1.tracks = ['track:track2'];
+  section1.tracks = [track2];
 
   // XXX_decacheWikiData
   album1.trackSections = [];