diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-21 10:58:55 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-05 21:02:48 -0300 |
commit | 218a99a3164e8ae6967335190b72fd36275d1892 (patch) | |
tree | 952373949aa36434398d60a8d3ca8d627b255c7b /test | |
parent | d194fc4f537ee79b0558b54ff2e1fdc3e9cbf4d9 (diff) |
data, test: track: inherit album props more declaratively
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/data/things/track.js | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index 383e3e3f..d0e50c7f 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -3,6 +3,7 @@ import thingConstructors from '#things'; const { Album, + Artist, Thing, Track, TrackGroup, @@ -20,55 +21,65 @@ function stubAlbum(tracks) { } t.test(`Track.coverArtDate`, t => { - t.plan(5); + t.plan(6); - // Priority order is as follows, with the last (trackCoverArtDate) being - // greatest priority. - const albumDate = new Date('2010-10-10'); const albumTrackArtDate = new Date('2012-12-12'); - const trackDateFirstReleased = new Date('2008-08-08'); const trackCoverArtDate = new Date('2009-09-09'); + const dummyContribs = [{who: 'Test Artist', what: null}] const track = new Track(); track.directory = 'foo'; + track.coverArtistContribsByRef = dummyContribs; const album = stubAlbum([track]); + const artist = new Artist(); + artist.name = 'Test Artist'; + track.albumData = [album]; + track.artistData = [artist]; + + const XXX_CLEAR_TRACK_ALBUM_CACHE = () => { + // XXX clear cache so change in album's property is reflected + track.albumData = []; + track.albumData = [album]; + }; // 1. coverArtDate defaults to null t.equal(track.coverArtDate, null); - // 2. coverArtDate inherits album release date + // 2. coverArtDate inherits album trackArtDate - album.date = albumDate; + album.trackArtDate = albumTrackArtDate; - // XXX clear cache so change in album's property is reflected - track.albumData = []; - track.albumData = [album]; + XXX_CLEAR_TRACK_ALBUM_CACHE(); - t.equal(track.coverArtDate, albumDate); + t.equal(track.coverArtDate, albumTrackArtDate); - // 3. coverArtDate inherits album trackArtDate + // 3. coverArtDate is own value - album.trackArtDate = albumTrackArtDate; + track.coverArtDate = trackCoverArtDate; - // XXX clear cache again - track.albumData = []; - track.albumData = [album]; + t.equal(track.coverArtDate, trackCoverArtDate); - t.equal(track.coverArtDate, albumTrackArtDate); + // 4. coverArtDate is null if track is missing coverArtists - // 4. coverArtDate is overridden dateFirstReleased + track.coverArtistContribsByRef = []; - track.dateFirstReleased = trackDateFirstReleased; + t.equal(track.coverArtDate, null); - t.equal(track.coverArtDate, trackDateFirstReleased); + // 5. coverArtDate is not null if album specifies trackCoverArtistContribs - // 5. coverArtDate is overridden coverArtDate + album.trackCoverArtistContribsByRef = dummyContribs; - track.coverArtDate = trackCoverArtDate; + XXX_CLEAR_TRACK_ALBUM_CACHE(); t.equal(track.coverArtDate, trackCoverArtDate); + + // 6. coverArtDate is null if track disables unique cover artwork + + track.disableUniqueCoverArt = true; + + t.equal(track.coverArtDate, null); }); |