From a8718915ffcb9b3977ccab479817c8bd8d9b20c6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Sep 2023 15:39:40 -0300 Subject: test: Track.commentatorArtists (unit) --- test/unit/data/things/track.js | 68 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'test/unit') diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index 8aecf789..5e7fd829 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -32,14 +32,20 @@ function stubTrack(directory = 'foo') { function stubTrackAndAlbum(trackDirectory = 'foo', albumDirectory = 'bar') { const track = stubTrack(trackDirectory); const album = stubAlbum([track], albumDirectory); + return {track, album}; } -function stubArtistAndContribs() { +function stubArtist(artistName = `Test Artist`) { const artist = new Artist(); - artist.name = `Test Artist`; + artist.name = artistName; + + return artist; +} - const contribs = [{who: `Test Artist`, what: null}]; +function stubArtistAndContribs(artistName = `Test Artist`) { + const artist = stubArtist(artistName); + const contribs = [{who: artistName, what: null}]; const badContribs = [{who: `Figment of Your Imagination`, what: null}]; return {artist, contribs, badContribs}; @@ -160,6 +166,62 @@ t.test(`Track.color`, t => { `color #5: must be set to valid color`); }); +t.test(`Track.commentatorArtists`, t => { + t.plan(6); + + const track = new Track(); + const artist1 = stubArtist(`SnooPING`); + const artist2 = stubArtist(`ASUsual`); + const artist3 = stubArtist(`Icy`); + + linkAndBindWikiData({ + trackData: [track], + artistData: [artist1, artist2, artist3], + }); + + track.commentary = + `SnooPING:\n` + + `Wow.\n`; + + t.same(track.commentatorArtists, [artist1], + `Track.commentatorArtists #1: works with one commentator`); + + track.commentary += + `ASUsual:\n` + + `Yes!\n`; + + t.same(track.commentatorArtists, [artist1, artist2], + `Track.commentatorArtists #2: works with two commentators`); + + track.commentary += + `Icy:\n` + + `Incredible.\n`; + + t.same(track.commentatorArtists, [artist1, artist2, artist3], + `Track.commentatorArtists #3: works with boldface name`); + + track.commentary = + `Icy: (project manager)\n` + + `Very good track.\n`; + + t.same(track.commentatorArtists, [artist3], + `Track.commentatorArtists #4: works with parenthical accent`); + + track.commentary += + `SNooPING ASUsual Icy:\n` + + `WITH ALL THREE POWERS COMBINED...`; + + t.same(track.commentatorArtists, [artist3], + `Track.commentatorArtists #5: ignores artist names not found`); + + track.commentary += + `Icy:\n` + + `I'm back!\n`; + + t.same(track.commentatorArtists, [artist3], + `Track.commentatorArtists #6: ignores duplicate artist`); +}); + t.test(`Track.coverArtDate`, t => { t.plan(8); -- cgit 1.3.0-6-gf8a5