From 6cbd8ee458a25ed8608760f8867008aa8f55d5e3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 18 Nov 2023 19:54:37 -0400 Subject: test: Track.commentatorArtists: update overall --- test/unit/data/things/track.js | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'test/unit/data/things') diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index 806efbf1..571624a5 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -214,7 +214,7 @@ t.test(`Track.color`, t => { }); t.test(`Track.commentatorArtists`, t => { - t.plan(6); + t.plan(8); const track = new Track(); const artist1 = stubArtist(`SnooPING`); @@ -226,47 +226,67 @@ t.test(`Track.commentatorArtists`, t => { artistData: [artist1, artist2, artist3], }); - track.commentary = + // Keep track of the last commentary string in a separate value, since + // the track.commentary property exposes as a completely different format + // (i.e. an array of objects, one for each entry), and so isn't compatible + // with the += operator on its own. + let commentary; + + track.commentary = commentary = `SnooPING:\n` + `Wow.\n`; t.same(track.commentatorArtists, [artist1], `Track.commentatorArtists #1: works with one commentator`); - track.commentary += + track.commentary = commentary += `ASUsual:\n` + `Yes!\n`; t.same(track.commentatorArtists, [artist1, artist2], `Track.commentatorArtists #2: works with two commentators`); - track.commentary += - `Icy:\n` + + track.commentary = commentary += + `Icy|Icy What You Did There:\n` + `Incredible.\n`; t.same(track.commentatorArtists, [artist1, artist2, artist3], - `Track.commentatorArtists #3: works with boldface name`); + `Track.commentatorArtists #3: works with custom artist text`); - track.commentary = + track.commentary = commentary = `Icy: (project manager)\n` + `Very good track.\n`; t.same(track.commentatorArtists, [artist3], - `Track.commentatorArtists #4: works with parenthical accent`); + `Track.commentatorArtists #4: works with annotation`); - track.commentary += - `SNooPING ASUsual Icy:\n` + - `WITH ALL THREE POWERS COMBINED...`; + track.commentary = commentary = + `Icy: (project manager, 08/15/2023)\n` + + `Very very good track.\n`; + + t.same(track.commentatorArtists, [artist3], + `Track.commentatorArtists #5: works with date`); + + track.commentary = commentary += + `Ohohohoho:\n` + + `OHOHOHOHOHOHO...\n`; t.same(track.commentatorArtists, [artist3], - `Track.commentatorArtists #5: ignores artist names not found`); + `Track.commentatorArtists #6: ignores artist names not found`); - track.commentary += + track.commentary = commentary += `Icy:\n` + `I'm back!\n`; t.same(track.commentatorArtists, [artist3], - `Track.commentatorArtists #6: ignores duplicate artist`); + `Track.commentatorArtists #7: ignores duplicate artist`); + + track.commentary = commentary += + `SNooPING, ASUsual, Icy:\n` + + `WITH ALL THREE POWERS COMBINED...`; + + t.same(track.commentatorArtists, [artist3, artist1, artist2], + `Track.commentatorArtists #8: works with more than one artist in one entry`); }); t.test(`Track.coverArtistContribs`, t => { -- cgit 1.3.0-6-gf8a5 From a6dedb0b17f514e408919240c060072df2b179dd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 18 Nov 2023 20:18:42 -0400 Subject: test: Track.color: mock fake album for updated wikiData validator --- test/unit/data/things/track.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/unit/data/things') diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index 806efbf1..51f86070 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -189,13 +189,14 @@ t.test(`Track.color`, t => { // connection breaks for some future reason (with the album still present), // Track.color should still inherit directly from the album. wikiData.albumData = [ - new Proxy({ + { + constructor: {[Thing.referenceType]: 'album'}, color: '#abcdef', tracks: [track], trackSections: [ {color: '#baaaad', tracks: []}, ], - }, {getPrototypeOf: () => Album.prototype}), + }, ]; linkWikiDataArrays(); -- cgit 1.3.0-6-gf8a5 From 9f58ba688c8a6ac3acf7b4bc435e2ccaed20b011 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 24 Nov 2023 15:01:33 -0400 Subject: test: isCommentary: basic unit test update --- test/unit/data/things/validators.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'test/unit/data/things') diff --git a/test/unit/data/things/validators.js b/test/unit/data/things/validators.js index bb33bf86..aa56a10e 100644 --- a/test/unit/data/things/validators.js +++ b/test/unit/data/things/validators.js @@ -149,13 +149,18 @@ t.test('isColor', t => { }); t.test('isCommentary', t => { - t.plan(6); + t.plan(9); + + // TODO: Test specific error messages. t.ok(isCommentary(`Toby Fox:\ndogsong.mp3`)); - t.ok(isCommentary(`Technically, this works:`)); - t.ok(isCommentary(`Whodunnit:`)); - t.throws(() => isCommentary(123), TypeError); - t.throws(() => isCommentary(``), TypeError); - t.throws(() => isCommentary(`Toby Fox:`)); + t.ok(isCommentary(`Toby Fox: (music)\ndogsong.mp3`)); + t.throws(() => isCommentary(`dogsong.mp3\nToby Fox:\ndogsong.mp3`)); + t.throws(() => isCommentary(`Toby Fox: dogsong.mp3`)); + t.throws(() => isCommentary(`Toby Fox: (music) dogsong.mp3`)); + t.throws(() => isCommentary(`I Have Nothing To Say:`)); + t.throws(() => isCommentary(123)); + t.throws(() => isCommentary(``)); + t.throws(() => isCommentary(`Technically, ah, er:\nCorrect`)); }); t.test('isContribution', t => { -- cgit 1.3.0-6-gf8a5 From 7215aef076f9734f35dc4f25e54fbe2371630c5f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 28 Nov 2023 13:23:17 -0400 Subject: data, test: album.trackData -> album.ownTrackData --- test/unit/data/things/album.js | 20 ++++++++++++-------- test/unit/data/things/track.js | 16 +++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'test/unit/data/things') diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js index 76a2b90f..5a1261a4 100644 --- a/test/unit/data/things/album.js +++ b/test/unit/data/things/album.js @@ -204,11 +204,13 @@ t.test(`Album.tracks`, t => { const track1 = stubTrack('track1'); const track2 = stubTrack('track2'); const track3 = stubTrack('track3'); + const tracks = [track1, track2, track3]; - linkAndBindWikiData({ - albumData: [album], - trackData: [track1, track2, track3], - }); + album.ownTrackData = tracks; + + for (const track of tracks) { + track.albumData = [album]; + } t.same(album.tracks, [], `Album.tracks #1: defaults to empty array`); @@ -259,11 +261,13 @@ t.test(`Album.trackSections`, t => { const track2 = stubTrack('track2'); const track3 = stubTrack('track3'); const track4 = stubTrack('track4'); + const tracks = [track1, track2, track3, track4]; - linkAndBindWikiData({ - albumData: [album], - trackData: [track1, track2, track3, track4], - }); + album.ownTrackData = tracks; + + for (const track of tracks) { + track.albumData = [album]; + } album.trackSections = [ {tracks: ['track:track1', 'track:track2']}, diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index f84ba1cb..57bd4253 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -80,8 +80,8 @@ t.test(`Track.album`, t => { track1.albumData = [album1, album2]; track2.albumData = [album1, album2]; - album1.trackData = [track1, track2]; - album2.trackData = [track1, track2]; + album1.ownTrackData = [track1, track2]; + album2.ownTrackData = [track1, track2]; album1.trackSections = [{tracks: ['track:track1']}]; album2.trackSections = [{tracks: ['track:track2']}]; @@ -98,13 +98,13 @@ t.test(`Track.album`, t => { t.equal(track1.album, null, `album #4: is null when track missing albumData`); - album1.trackData = []; + album1.ownTrackData = []; track1.albumData = [album1, album2]; t.equal(track1.album, null, - `album #5: is null when album missing trackData`); + `album #5: is null when album missing ownTrackData`); - album1.trackData = [track1, track2]; + album1.ownTrackData = [track1, track2]; album1.trackSections = [{tracks: ['track:track2']}]; // XXX_decacheWikiData @@ -165,7 +165,7 @@ t.test(`Track.color`, t => { const {track, album} = stubTrackAndAlbum(); - const {wikiData, linkWikiDataArrays, XXX_decacheWikiData} = linkAndBindWikiData({ + const {XXX_decacheWikiData} = linkAndBindWikiData({ albumData: [album], trackData: [track], }); @@ -188,7 +188,7 @@ t.test(`Track.color`, t => { // track's album will always have a corresponding track section. But if that // connection breaks for some future reason (with the album still present), // Track.color should still inherit directly from the album. - wikiData.albumData = [ + track.albumData = [ { constructor: {[Thing.referenceType]: 'album'}, color: '#abcdef', @@ -199,8 +199,6 @@ t.test(`Track.color`, t => { }, ]; - linkWikiDataArrays(); - t.equal(track.color, '#abcdef', `color #3: inherits from album without matching track section`); -- cgit 1.3.0-6-gf8a5