From e904989c762a761227a1e6d7e67d1cfffa264978 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 24 Apr 2024 11:43:02 -0300 Subject: test: misc adaptations for who/what -> artist/annotation --- test/snapshot/generateAlbumReleaseInfo.js | 14 +++--- test/snapshot/generateAlbumTrackList.js | 6 +-- test/snapshot/generateTrackReleaseInfo.js | 4 +- test/snapshot/linkContribution.js | 20 ++++---- test/unit/content/dependencies/linkContribution.js | 54 +++++++++++----------- test/unit/data/things/album.js | 4 +- test/unit/data/things/art-tag.js | 4 +- test/unit/data/things/track.js | 42 ++++++++--------- test/unit/data/things/validators.js | 14 +++--- 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/test/snapshot/generateAlbumReleaseInfo.js b/test/snapshot/generateAlbumReleaseInfo.js index 3dea1196..a109912f 100644 --- a/test/snapshot/generateAlbumReleaseInfo.js +++ b/test/snapshot/generateAlbumReleaseInfo.js @@ -8,22 +8,22 @@ testContentFunctions(t, 'generateAlbumReleaseInfo (snapshot)', async (t, evaluat name: 'generateAlbumReleaseInfo', args: [{ artistContribs: [ - {who: {name: 'Toby Fox', directory: 'toby-fox', urls: null}, what: 'music probably'}, - {who: {name: 'Tensei', directory: 'tensei', urls: ['https://tenseimusic.bandcamp.com/']}, what: 'hot jams'}, + {artist: {name: 'Toby Fox', directory: 'toby-fox', urls: null}, annotation: 'music probably'}, + {artist: {name: 'Tensei', directory: 'tensei', urls: ['https://tenseimusic.bandcamp.com/']}, annotation: 'hot jams'}, ], coverArtistContribs: [ - {who: {name: 'Hanni Brosh', directory: 'hb', urls: null}, what: null}, + {artist: {name: 'Hanni Brosh', directory: 'hb', urls: null}, annotation: null}, ], wallpaperArtistContribs: [ - {who: {name: 'Hanni Brosh', directory: 'hb', urls: null}, what: null}, - {who: {name: 'Niklink', directory: 'niklink', urls: null}, what: 'edits'}, + {artist: {name: 'Hanni Brosh', directory: 'hb', urls: null}, annotation: null}, + {artist: {name: 'Niklink', directory: 'niklink', urls: null}, annotation: 'edits'}, ], bannerArtistContribs: [ - {who: {name: 'Hanni Brosh', directory: 'hb', urls: null}, what: null}, - {who: {name: 'Niklink', directory: 'niklink', urls: null}, what: 'edits'}, + {artist: {name: 'Hanni Brosh', directory: 'hb', urls: null}, annotation: null}, + {artist: {name: 'Niklink', directory: 'niklink', urls: null}, annotation: 'edits'}, ], name: 'AlterniaBound', diff --git a/test/snapshot/generateAlbumTrackList.js b/test/snapshot/generateAlbumTrackList.js index 181cc1d2..3a23e3a8 100644 --- a/test/snapshot/generateAlbumTrackList.js +++ b/test/snapshot/generateAlbumTrackList.js @@ -10,12 +10,12 @@ testContentFunctions(t, 'generateAlbumTrackList (snapshot)', async (t, evaluate) }); const contribs1 = [ - {who: {name: 'Apricot', directory: 'apricot', urls: null}}, + {artist: {name: 'Apricot', directory: 'apricot', urls: null}}, ]; const contribs2 = [ - {who: {name: 'Apricot', directory: 'apricot', urls: null}}, - {who: {name: 'Peach', directory: 'peach', urls: ['https://peach.bandcamp.com/']}}, + {artist: {name: 'Apricot', directory: 'apricot', urls: null}}, + {artist: {name: 'Peach', directory: 'peach', urls: ['https://peach.bandcamp.com/']}}, ]; const color1 = '#fb07ff'; diff --git a/test/snapshot/generateTrackReleaseInfo.js b/test/snapshot/generateTrackReleaseInfo.js index c72344b9..78f0fee7 100644 --- a/test/snapshot/generateTrackReleaseInfo.js +++ b/test/snapshot/generateTrackReleaseInfo.js @@ -4,8 +4,8 @@ import {testContentFunctions} from '#test-lib'; testContentFunctions(t, 'generateTrackReleaseInfo (snapshot)', async (t, evaluate) => { await evaluate.load(); - const artistContribs = [{who: {name: 'Toby Fox', directory: 'toby-fox', urls: null}, what: null}]; - const coverArtistContribs = [{who: {name: 'Alpaca', directory: 'alpaca', urls: null}, what: '🔥'}]; + const artistContribs = [{artist: {name: 'Toby Fox', directory: 'toby-fox', urls: null}, annotation: null}]; + const coverArtistContribs = [{artist: {name: 'Alpaca', directory: 'alpaca', urls: null}, annotation: '🔥'}]; evaluate.snapshot('basic behavior', { name: 'generateTrackReleaseInfo', diff --git a/test/snapshot/linkContribution.js b/test/snapshot/linkContribution.js index ebd3be58..1043ddc6 100644 --- a/test/snapshot/linkContribution.js +++ b/test/snapshot/linkContribution.js @@ -9,25 +9,25 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => { name: 'linkContribution', multiple: [ {args: [ - {who: { + {artist: { name: 'Clark Powell', directory: 'clark-powell', urls: ['https://soundcloud.com/plazmataz'], - }, what: null}, + }, annotation: null}, ]}, {args: [ - {who: { + {artist: { name: 'Grounder & Scratch', directory: 'the-big-baddies', urls: [], - }, what: 'Snooping'}, + }, annotation: 'Snooping'}, ]}, {args: [ - {who: { + {artist: { name: 'Toby Fox', directory: 'toby-fox', urls: ['https://tobyfox.bandcamp.com/', 'https://toby.fox/'], - }, what: 'Arrangement'}, + }, annotation: 'Arrangement'}, ]}, ], slots, @@ -65,7 +65,7 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => { evaluate.snapshot('loads of links (inline)', { name: 'linkContribution', args: [ - {who: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [ + {artist: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [ 'https://loremipsum.io', 'https://loremipsum.io/generator/', 'https://loremipsum.io/#meaning', @@ -74,7 +74,7 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => { 'https://loremipsum.io/#when-to-use-lorem-ipsum', 'https://loremipsum.io/#lorem-ipsum-all-the-things', 'https://loremipsum.io/#original-source', - ]}, what: null}, + ]}, annotation: null}, ], slots: {showIcons: true}, }); @@ -82,7 +82,7 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => { evaluate.snapshot('loads of links (tooltip)', { name: 'linkContribution', args: [ - {who: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [ + {artist: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [ 'https://loremipsum.io', 'https://loremipsum.io/generator/', 'https://loremipsum.io/#meaning', @@ -91,7 +91,7 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => { 'https://loremipsum.io/#when-to-use-lorem-ipsum', 'https://loremipsum.io/#lorem-ipsum-all-the-things', 'https://loremipsum.io/#original-source', - ]}, what: null}, + ]}, annotation: null}, ], slots: {showIcons: true, iconMode: 'tooltip'}, }); diff --git a/test/unit/content/dependencies/linkContribution.js b/test/unit/content/dependencies/linkContribution.js index 94908901..ab45b03a 100644 --- a/test/unit/content/dependencies/linkContribution.js +++ b/test/unit/content/dependencies/linkContribution.js @@ -2,27 +2,27 @@ import t from 'tap'; import {testContentFunctions} from '#test-lib'; t.test('generateContributionLinks (unit)', async t => { - const who1 = { + const artist1 = { name: 'Clark Powell', directory: 'clark-powell', urls: ['https://soundcloud.com/plazmataz'], }; - const who2 = { + const artist2 = { name: 'Grounder & Scratch', directory: 'the-big-baddies', urls: [], }; - const who3 = { + const artist3 = { name: 'Toby Fox', directory: 'toby-fox', urls: ['https://tobyfox.bandcamp.com/', 'https://toby.fox/'], }; - const what1 = null; - const what2 = 'Snooping'; - const what3 = 'Arrangement'; + const annotation1 = null; + const annotation2 = 'Snooping'; + const annotation3 = 'Arrangement'; await testContentFunctions(t, 'generateContributionLinks (unit 1)', async (t, evaluate) => { const slots = { @@ -34,14 +34,14 @@ t.test('generateContributionLinks (unit)', async t => { mock: evaluate.mock(mock => ({ linkArtist: { relations: mock.function('linkArtist.relations', () => ({})) - .args([undefined, who1]).next() - .args([undefined, who2]).next() - .args([undefined, who3]), + .args([undefined, artist1]).next() + .args([undefined, artist2]).next() + .args([undefined, artist3]), data: mock.function('linkArtist.data', () => ({})) - .args([who1]).next() - .args([who2]).next() - .args([who3]), + .args([artist1]).next() + .args([artist2]).next() + .args([artist3]), // This can be tweaked to return a specific (mocked) template // for each artist if we need to test for slots in the future. @@ -51,9 +51,9 @@ t.test('generateContributionLinks (unit)', async t => { linkExternalAsIcon: { data: mock.function('linkExternalAsIcon.data', () => ({})) - .args([who1.urls[0]]).next() - .args([who3.urls[0]]).next() - .args([who3.urls[1]]), + .args([artist1.urls[0]]).next() + .args([artist3.urls[0]]).next() + .args([artist3.urls[1]]), generate: mock.function('linkExternalAsIcon.generate', () => 'icon') .repeat(3), @@ -64,9 +64,9 @@ t.test('generateContributionLinks (unit)', async t => { evaluate({ name: 'linkContribution', multiple: [ - {args: [{who: who1, what: what1}]}, - {args: [{who: who2, what: what2}]}, - {args: [{who: who3, what: what3}]}, + {args: [{artist: artist1, annotation: annotation1}]}, + {args: [{artist: artist2, annotation: annotation2}]}, + {args: [{artist: artist3, annotation: annotation3}]}, ], slots, }); @@ -82,14 +82,14 @@ t.test('generateContributionLinks (unit)', async t => { mock: evaluate.mock(mock => ({ linkArtist: { relations: mock.function('linkArtist.relations', () => ({})) - .args([undefined, who1]).next() - .args([undefined, who2]).next() - .args([undefined, who3]), + .args([undefined, artist1]).next() + .args([undefined, artist2]).next() + .args([undefined, artist3]), data: mock.function('linkArtist.data', () => ({})) - .args([who1]).next() - .args([who2]).next() - .args([who3]), + .args([artist1]).next() + .args([artist2]).next() + .args([artist3]), generate: mock.function(() => 'artist link') .repeat(3), @@ -112,9 +112,9 @@ t.test('generateContributionLinks (unit)', async t => { evaluate({ name: 'linkContribution', multiple: [ - {args: [{who: who1, what: what1}]}, - {args: [{who: who2, what: what2}]}, - {args: [{who: who3, what: what3}]}, + {args: [{artist: artist1, annotation: annotation1}]}, + {args: [{artist: artist2, annotation: annotation2}]}, + {args: [{artist: artist3, annotation: annotation3}]}, ], slots, }); diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js index 46ea83b0..bf9992ae 100644 --- a/test/unit/data/things/album.js +++ b/test/unit/data/things/album.js @@ -21,8 +21,8 @@ function stubArtistAndContribs() { const artist = new Artist(); artist.name = `Test Artist`; - const contribs = [{who: `Test Artist`, what: null}]; - const badContribs = [{who: `Figment of Your Imagination`, what: null}]; + const contribs = [{artist: `Test Artist`, annotation: null}]; + const badContribs = [{artist: `Figment of Your Imagination`, annotation: null}]; return {artist, contribs, badContribs}; } diff --git a/test/unit/data/things/art-tag.js b/test/unit/data/things/art-tag.js index 561c93ef..836bb1c3 100644 --- a/test/unit/data/things/art-tag.js +++ b/test/unit/data/things/art-tag.js @@ -43,8 +43,8 @@ function stubArtist(artistName = `Test Artist`) { function stubArtistAndContribs(artistName = `Test Artist`) { const artist = stubArtist(artistName); - const contribs = [{who: artistName, what: null}]; - const badContribs = [{who: `Figment of Your Imagination`, what: null}]; + const contribs = [{artist: artistName, annotation: null}]; + const badContribs = [{artist: `Figment of Your Imagination`, annotation: null}]; return {artist, contribs, badContribs}; } diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index b1c1611e..57a297db 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -46,8 +46,8 @@ function stubArtist(artistName = `Test Artist`) { function stubArtistAndContribs(artistName = `Test Artist`) { const artist = stubArtist(artistName); - const contribs = [{who: artistName, what: null}]; - const badContribs = [{who: `Figment of Your Imagination`, what: null}]; + const contribs = [{artist: artistName, annotation: null}]; + const badContribs = [{artist: `Figment of Your Imagination`, annotation: null}]; return {artist, contribs, badContribs}; } @@ -189,31 +189,31 @@ t.test(`Track.artistContribs`, t => { `artistContribs #1: defaults to empty array`); album.artistContribs = [ - {who: `Artist 1`, what: `composition`}, - {who: `Artist 2`, what: null}, + {artist: `Artist 1`, annotation: `composition`}, + {artist: `Artist 2`, annotation: null}, ]; XXX_decacheWikiData(); t.same(track.artistContribs, - [{who: artist1, what: `composition`}, {who: artist2, what: null}], + [{artist: artist1, annotation: `composition`}, {artist: artist2, annotation: null}], `artistContribs #2: inherits album artistContribs`); track.artistContribs = [ - {who: `Artist 1`, what: `arrangement`}, + {artist: `Artist 1`, annotation: `arrangement`}, ]; - t.same(track.artistContribs, [{who: artist1, what: `arrangement`}], + t.same(track.artistContribs, [{artist: artist1, annotation: `arrangement`}], `artistContribs #3: resolves from own value`); track.artistContribs = [ - {who: `Artist 1`, what: `snooping`}, - {who: `Artist 413`, what: `as`}, - {who: `Artist 2`, what: `usual`}, + {artist: `Artist 1`, annotation: `snooping`}, + {artist: `Artist 413`, annotation: `as`}, + {artist: `Artist 2`, annotation: `usual`}, ]; t.same(track.artistContribs, - [{who: artist1, what: `snooping`}, {who: artist2, what: `usual`}], + [{artist: artist1, annotation: `snooping`}, {artist: artist2, annotation: `usual`}], `artistContribs #4: filters out names without matches`); }); @@ -303,7 +303,7 @@ t.test(`Track.commentatorArtists`, t => { `Track.commentatorArtists #2: works with two commentators`); track.commentary = commentary += - `Icy|Icy What You Did There:\n` + + `Icy|Icy annotation You Did There:\n` + `Incredible.\n`; t.same(track.commentatorArtists, [artist1, artist2, artist3], @@ -362,31 +362,31 @@ t.test(`Track.coverArtistContribs`, t => { `coverArtistContribs #1: defaults to empty array`); album.trackCoverArtistContribs = [ - {who: `Artist 1`, what: `lines`}, - {who: `Artist 2`, what: null}, + {artist: `Artist 1`, annotation: `lines`}, + {artist: `Artist 2`, annotation: null}, ]; XXX_decacheWikiData(); t.same(track.coverArtistContribs, - [{who: artist1, what: `lines`}, {who: artist2, what: null}], + [{artist: artist1, annotation: `lines`}, {artist: artist2, annotation: null}], `coverArtistContribs #2: inherits album trackCoverArtistContribs`); track.coverArtistContribs = [ - {who: `Artist 1`, what: `collage`}, + {artist: `Artist 1`, annotation: `collage`}, ]; - t.same(track.coverArtistContribs, [{who: artist1, what: `collage`}], + t.same(track.coverArtistContribs, [{artist: artist1, annotation: `collage`}], `coverArtistContribs #3: resolves from own value`); track.coverArtistContribs = [ - {who: `Artist 1`, what: `snooping`}, - {who: `Artist 413`, what: `as`}, - {who: `Artist 2`, what: `usual`}, + {artist: `Artist 1`, annotation: `snooping`}, + {artist: `Artist 413`, annotation: `as`}, + {artist: `Artist 2`, annotation: `usual`}, ]; t.same(track.coverArtistContribs, - [{who: artist1, what: `snooping`}, {who: artist2, what: `usual`}], + [{artist: artist1, annotation: `snooping`}, {artist: artist2, annotation: `usual`}], `coverArtistContribs #4: filters out names without matches`); track.disableUniqueCoverArt = true; diff --git a/test/unit/data/things/validators.js b/test/unit/data/things/validators.js index eeb2465e..3a217d6f 100644 --- a/test/unit/data/things/validators.js +++ b/test/unit/data/things/validators.js @@ -280,17 +280,17 @@ t.test('isContentString', t => { t.test('isContribution', t => { t.plan(4); - t.ok(isContribution({who: 'artist:toby-fox', what: 'Music'})); - t.ok(isContribution({who: 'Toby Fox'})); - t.throws(() => isContribution(({who: 'group:umspaf', what: 'Organizing'})), - {errors: /who/}); - t.throws(() => isContribution(({who: 'artist:toby-fox', what: 123})), - {errors: /what/}); + t.ok(isContribution({artist: 'artist:toby-fox', annotation: 'Music'})); + t.ok(isContribution({artist: 'Toby Fox'})); + t.throws(() => isContribution(({artist: 'group:umspaf', annotation: 'Organizing'})), + {errors: /artist/}); + t.throws(() => isContribution(({artist: 'artist:toby-fox', annotation: 123})), + {errors: /annotation/}); }); t.test('isContributionList', t => { t.plan(4); - t.ok(isContributionList([{who: 'Beavis'}, {who: 'Butthead', what: 'Wrangling'}])); + t.ok(isContributionList([{artist: 'Beavis'}, {artist: 'Butthead', annotation: 'Wrangling'}])); t.ok(isContributionList([])); t.throws(() => isContributionList(2)); t.throws(() => isContributionList(['Charlie', 'Woodstock'])); -- cgit 1.3.0-6-gf8a5