1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
import t from 'tap';
import thingConstructors from '#things';
const {
Album,
Artist,
Thing,
Track,
TrackGroup,
} = thingConstructors;
function stubAlbum(tracks) {
const album = new Album();
album.trackSections = [
{
tracksByRef: tracks.map(t => Thing.getReference(t)),
},
];
album.trackData = tracks;
return album;
}
t.test(`Track.coverArtDate`, t => {
t.plan(6);
const albumTrackArtDate = new Date('2012-12-12');
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 trackArtDate
album.trackArtDate = albumTrackArtDate;
XXX_CLEAR_TRACK_ALBUM_CACHE();
t.equal(track.coverArtDate, albumTrackArtDate);
// 3. coverArtDate is own value
track.coverArtDate = trackCoverArtDate;
t.equal(track.coverArtDate, trackCoverArtDate);
// 4. coverArtDate is null if track is missing coverArtists
track.coverArtistContribsByRef = [];
t.equal(track.coverArtDate, null);
// 5. coverArtDate is not null if album specifies trackCoverArtistContribs
album.trackCoverArtistContribsByRef = dummyContribs;
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);
});
|