« get me outta code hell

test: update linkContribution (snapshot, unit) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-18 10:47:09 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:16 -0300
commitf72675be540682b4cd657b2a1f3775cf59abcc06 (patch)
treef3a5dc4c3b869b7eae57df548877008706668510
parent9edbf2deb022b0b2b3699bf0ffa3b8c6aa6e1c98 (diff)
test: update linkContribution (snapshot, unit)
Sorry, this is just maintaining the test paths that exist and
dropping the ones which don't apply anymore.
-rw-r--r--tap-snapshots/test/snapshot/linkContribution.js.test.cjs179
-rw-r--r--test/snapshot/linkContribution.js45
-rw-r--r--test/unit/content/dependencies/linkContribution.js41
3 files changed, 102 insertions, 163 deletions
diff --git a/tap-snapshots/test/snapshot/linkContribution.js.test.cjs b/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
index 92d697e7..c1631d2b 100644
--- a/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
+++ b/tap-snapshots/test/snapshot/linkContribution.js.test.cjs
@@ -5,159 +5,114 @@
  * Make sure to inspect the output below.  Do not ignore changes!
  */
 'use strict'
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > loads of links (inline) 1`] = `
-<span class="contribution nowrap"><a href="artist/lorem-ipsum-lover/">Lorem Ipsum Lover</a> (<span class="icons icons-inline"><a class="icon" href="https://loremipsum.io">
-            <svg>
-                <title>loremipsum.io</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a>, <a class="icon" href="https://loremipsum.io/generator/">
-            <svg>
-                <title>loremipsum.io</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a>, <a class="icon" href="https://loremipsum.io/#meaning">
-            <svg>
-                <title>loremipsum.io</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a>, <a class="icon" href="https://loremipsum.io/#usage-and-examples">
-            <svg>
-                <title>loremipsum.io</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a></span>)</span>
-`
-
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > loads of links (tooltip) 1`] = `
-<span class="contribution"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/lorem-ipsum-lover/">Lorem Ipsum Lover</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://loremipsum.io">
+exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > loads of links 1`] = `
+<span class="contribution nowrap"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/lorem-ipsum-lover/">Lorem Ipsum Lover</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://loremipsum.io">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/generator/">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/generator/">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#meaning">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#meaning">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#usage-and-examples">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#usage-and-examples">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#controversy">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#controversy">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#when-to-use-lorem-ipsum">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#when-to-use-lorem-ipsum">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#lorem-ipsum-all-the-things">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#lorem-ipsum-all-the-things">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span><a class="icon has-text" href="https://loremipsum.io/#original-source">
+                </a>
+                <span class="icon-platform">Other</span>
+                <a class="icon has-text" href="https://loremipsum.io/#original-source">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">loremipsum.io</span>
-                </a><span class="icon-platform">Other</span></span></span></span></span>
+                </a>
+                <span class="icon-platform">Other</span></span></span></span></span>
 `
 
 exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > no accents 1`] = `
-<a href="artist/clark-powell/">Clark Powell</a>
-<a href="artist/the-big-baddies/">Grounder &amp; Scratch</a>
-<a href="artist/toby-fox/">Toby Fox</a>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/the-big-baddies/">Grounder &amp; Scratch</a></span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/toby-fox/">Toby Fox</a></span>
 `
 
 exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > no preventWrapping 1`] = `
-<span class="contribution"><a href="artist/clark-powell/">Clark Powell</a> (<span class="icons icons-inline"><a class="icon" href="https://soundcloud.com/plazmataz">
-            <svg>
-                <title>SoundCloud</title>
-                <use href="static/misc/icons.svg#icon-soundcloud"></use>
-            </svg>
-        </a></span>)</span>
-<span class="contribution"><a href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
-<span class="contribution"><a href="artist/toby-fox/">Toby Fox</a> (Arrangement) (<span class="icons icons-inline"><a class="icon" href="https://tobyfox.bandcamp.com/">
-            <svg>
-                <title>Bandcamp</title>
-                <use href="static/misc/icons.svg#icon-bandcamp"></use>
-            </svg>
-        </a>, <a class="icon" href="https://toby.fox/">
-            <svg>
-                <title>toby.fox</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a></span>)</span>
+<span class="contribution"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://soundcloud.com/plazmataz">
+                    <svg><use href="static/misc/icons.svg#icon-soundcloud"></use></svg>
+                    <span class="icon-text">plazmataz</span>
+                </a>
+                <span class="icon-platform">SoundCloud</span></span></span></span></span>
+<span class="contribution"><a class="text-with-tooltip-interaction-cue" href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
+<span class="contribution"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/toby-fox/">Toby Fox</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://tobyfox.bandcamp.com/">
+                    <svg><use href="static/misc/icons.svg#icon-bandcamp"></use></svg>
+                    <span class="icon-text">tobyfox</span>
+                </a>
+                <span class="icon-platform">Bandcamp</span>
+                <a class="icon has-text" href="https://toby.fox/">
+                    <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
+                    <span class="icon-text">toby.fox</span>
+                </a>
+                <span class="icon-platform">Other</span></span></span></span> (Arrangement)</span>
 `
 
 exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > only showContribution 1`] = `
-<a href="artist/clark-powell/">Clark Powell</a>
-<span class="contribution nowrap"><a href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
-<span class="contribution nowrap"><a href="artist/toby-fox/">Toby Fox</a> (Arrangement)</span>
-`
-
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > only showIcons (inline) 1`] = `
-<span class="contribution nowrap"><a href="artist/clark-powell/">Clark Powell</a> (<span class="icons icons-inline"><a class="icon" href="https://soundcloud.com/plazmataz">
-            <svg>
-                <title>SoundCloud</title>
-                <use href="static/misc/icons.svg#icon-soundcloud"></use>
-            </svg>
-        </a></span>)</span>
-<a href="artist/the-big-baddies/">Grounder &amp; Scratch</a>
-<span class="contribution nowrap"><a href="artist/toby-fox/">Toby Fox</a> (<span class="icons icons-inline"><a class="icon" href="https://tobyfox.bandcamp.com/">
-            <svg>
-                <title>Bandcamp</title>
-                <use href="static/misc/icons.svg#icon-bandcamp"></use>
-            </svg>
-        </a>, <a class="icon" href="https://toby.fox/">
-            <svg>
-                <title>toby.fox</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a></span>)</span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/toby-fox/">Toby Fox</a> (Arrangement)</span>
 `
 
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > only showIcons (tooltip) 1`] = `
-<span class="contribution"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://soundcloud.com/plazmataz">
+exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > only showExternalLinks 1`] = `
+<span class="contribution nowrap"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://soundcloud.com/plazmataz">
                     <svg><use href="static/misc/icons.svg#icon-soundcloud"></use></svg>
                     <span class="icon-text">plazmataz</span>
-                </a><span class="icon-platform">SoundCloud</span></span></span></span></span>
-<span class="contribution nowrap"><a href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
+                </a>
+                <span class="icon-platform">SoundCloud</span></span></span></span></span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/the-big-baddies/">Grounder &amp; Scratch</a></span>
 <span class="contribution nowrap"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/toby-fox/">Toby Fox</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://tobyfox.bandcamp.com/">
                     <svg><use href="static/misc/icons.svg#icon-bandcamp"></use></svg>
                     <span class="icon-text">tobyfox</span>
-                </a><span class="icon-platform">Bandcamp</span><a class="icon has-text" href="https://toby.fox/">
+                </a>
+                <span class="icon-platform">Bandcamp</span>
+                <a class="icon has-text" href="https://toby.fox/">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">toby.fox</span>
-                </a><span class="icon-platform">Other</span></span></span></span> (Arrangement)</span>
+                </a>
+                <span class="icon-platform">Other</span></span></span></span></span>
 `
 
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > showContribution & showIcons (inline) 1`] = `
-<span class="contribution nowrap"><a href="artist/clark-powell/">Clark Powell</a> (<span class="icons icons-inline"><a class="icon" href="https://soundcloud.com/plazmataz">
-            <svg>
-                <title>SoundCloud</title>
-                <use href="static/misc/icons.svg#icon-soundcloud"></use>
-            </svg>
-        </a></span>)</span>
-<span class="contribution nowrap"><a href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
-<span class="contribution nowrap"><a href="artist/toby-fox/">Toby Fox</a> (Arrangement) (<span class="icons icons-inline"><a class="icon" href="https://tobyfox.bandcamp.com/">
-            <svg>
-                <title>Bandcamp</title>
-                <use href="static/misc/icons.svg#icon-bandcamp"></use>
-            </svg>
-        </a>, <a class="icon" href="https://toby.fox/">
-            <svg>
-                <title>toby.fox</title>
-                <use href="static/misc/icons.svg#icon-globe"></use>
-            </svg>
-        </a></span>)</span>
-`
-
-exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > showContribution & showIcons (tooltip) 1`] = `
-<span class="contribution"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://soundcloud.com/plazmataz">
+exports[`test/snapshot/linkContribution.js > TAP > linkContribution (snapshot) > showContribution & showExternalLinks 1`] = `
+<span class="contribution nowrap"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/clark-powell/">Clark Powell</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://soundcloud.com/plazmataz">
                     <svg><use href="static/misc/icons.svg#icon-soundcloud"></use></svg>
                     <span class="icon-text">plazmataz</span>
-                </a><span class="icon-platform">SoundCloud</span></span></span></span></span>
-<span class="contribution nowrap"><a href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
+                </a>
+                <span class="icon-platform">SoundCloud</span></span></span></span></span>
+<span class="contribution nowrap"><a class="text-with-tooltip-interaction-cue" href="artist/the-big-baddies/">Grounder &amp; Scratch</a> (Snooping)</span>
 <span class="contribution nowrap"><span class="text-with-tooltip"><span class="hoverable"><a class="text-with-tooltip-interaction-cue" href="artist/toby-fox/">Toby Fox</a></span><span class="tooltip icons icons-tooltip"><span class="tooltip-content"><a class="icon has-text" href="https://tobyfox.bandcamp.com/">
                     <svg><use href="static/misc/icons.svg#icon-bandcamp"></use></svg>
                     <span class="icon-text">tobyfox</span>
-                </a><span class="icon-platform">Bandcamp</span><a class="icon has-text" href="https://toby.fox/">
+                </a>
+                <span class="icon-platform">Bandcamp</span>
+                <a class="icon has-text" href="https://toby.fox/">
                     <svg><use href="static/misc/icons.svg#icon-globe"></use></svg>
                     <span class="icon-text">toby.fox</span>
-                </a><span class="icon-platform">Other</span></span></span></span> (Arrangement)</span>
+                </a>
+                <span class="icon-platform">Other</span></span></span></span> (Arrangement)</span>
 `
diff --git a/test/snapshot/linkContribution.js b/test/snapshot/linkContribution.js
index 1043ddc6..5844b0b9 100644
--- a/test/snapshot/linkContribution.js
+++ b/test/snapshot/linkContribution.js
@@ -33,53 +33,22 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => {
       slots,
     });
 
-  quickSnapshot('showContribution & showIcons (inline)', {
+  quickSnapshot('showContribution & showExternalLinks', {
     showContribution: true,
-    showIcons: true,
-    iconMode: 'inline',
-  });
-
-  quickSnapshot('showContribution & showIcons (tooltip)', {
-    showContribution: true,
-    showIcons: true,
-    iconMode: 'tooltip',
+    showExternalLinks: true,
   });
 
   quickSnapshot('only showContribution', {
     showContribution: true,
   });
 
-  quickSnapshot('only showIcons (inline)', {
-    showIcons: true,
-    iconMode: 'inline',
-  });
-
-  quickSnapshot('only showIcons (tooltip)', {
-    showContribution: true,
-    showIcons: true,
-    iconMode: 'tooltip',
+  quickSnapshot('only showExternalLinks', {
+    showExternalLinks: true,
   });
 
   quickSnapshot('no accents', {});
 
-  evaluate.snapshot('loads of links (inline)', {
-    name: 'linkContribution',
-    args: [
-      {artist: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [
-        'https://loremipsum.io',
-        'https://loremipsum.io/generator/',
-        'https://loremipsum.io/#meaning',
-        'https://loremipsum.io/#usage-and-examples',
-        'https://loremipsum.io/#controversy',
-        'https://loremipsum.io/#when-to-use-lorem-ipsum',
-        'https://loremipsum.io/#lorem-ipsum-all-the-things',
-        'https://loremipsum.io/#original-source',
-      ]}, annotation: null},
-    ],
-    slots: {showIcons: true},
-  });
-
-  evaluate.snapshot('loads of links (tooltip)', {
+  evaluate.snapshot('loads of links', {
     name: 'linkContribution',
     args: [
       {artist: {name: 'Lorem Ipsum Lover', directory: 'lorem-ipsum-lover', urls: [
@@ -93,12 +62,12 @@ testContentFunctions(t, 'linkContribution (snapshot)', async (t, evaluate) => {
         'https://loremipsum.io/#original-source',
       ]}, annotation: null},
     ],
-    slots: {showIcons: true, iconMode: 'tooltip'},
+    slots: {showExternalLinks: true},
   });
 
   quickSnapshot('no preventWrapping', {
     showContribution: true,
-    showIcons: true,
+    showExternalLinks: true,
     preventWrapping: false,
   });
 });
diff --git a/test/unit/content/dependencies/linkContribution.js b/test/unit/content/dependencies/linkContribution.js
index ab45b03a..e7a29310 100644
--- a/test/unit/content/dependencies/linkContribution.js
+++ b/test/unit/content/dependencies/linkContribution.js
@@ -27,18 +27,20 @@ t.test('generateContributionLinks (unit)', async t => {
   await testContentFunctions(t, 'generateContributionLinks (unit 1)', async (t, evaluate) => {
     const slots = {
       showContribution: true,
-      showIcons: true,
+      showExternalLinks: true,
     };
 
     await evaluate.load({
       mock: evaluate.mock(mock => ({
         linkArtist: {
-          relations: mock.function('linkArtist.relations', () => ({}))
+          relations: mock
+            .function('linkArtist.relations', () => ({}))
             .args([undefined, artist1]).next()
             .args([undefined, artist2]).next()
             .args([undefined, artist3]),
 
-          data: mock.function('linkArtist.data', () => ({}))
+          data: mock
+            .function('linkArtist.data', () => ({}))
             .args([artist1]).next()
             .args([artist2]).next()
             .args([artist3]),
@@ -49,13 +51,18 @@ t.test('generateContributionLinks (unit)', async t => {
             .repeat(3),
         },
 
-        linkExternalAsIcon: {
-          data: mock.function('linkExternalAsIcon.data', () => ({}))
+        generateExternalIcon: {
+          data: mock
+            .function('generateExternalIcon.data', () => ({}))
             .args([artist1.urls[0]]).next()
             .args([artist3.urls[0]]).next()
             .args([artist3.urls[1]]),
 
-          generate: mock.function('linkExternalAsIcon.generate', () => 'icon')
+          generate: mock
+            .function('generateExternalIcon.generate', () => ({
+              toString: () => 'icon',
+              setSlot: () => {},
+            }))
             .repeat(3),
         }
       })),
@@ -75,23 +82,26 @@ t.test('generateContributionLinks (unit)', async t => {
   await testContentFunctions(t, 'generateContributionLinks (unit 2)', async (t, evaluate) => {
     const slots = {
       showContribution: false,
-      showIcons: false,
+      showExternalLinks: false,
     };
 
     await evaluate.load({
       mock: evaluate.mock(mock => ({
         linkArtist: {
-          relations: mock.function('linkArtist.relations', () => ({}))
+          relations: mock
+            .function('linkArtist.relations', () => ({}))
             .args([undefined, artist1]).next()
             .args([undefined, artist2]).next()
             .args([undefined, artist3]),
 
-          data: mock.function('linkArtist.data', () => ({}))
+          data: mock
+            .function('linkArtist.data', () => ({}))
             .args([artist1]).next()
             .args([artist2]).next()
             .args([artist3]),
 
-          generate: mock.function(() => 'artist link')
+          generate: mock
+            .function(() => 'artist link')
             .repeat(3),
         },
 
@@ -99,11 +109,16 @@ t.test('generateContributionLinks (unit)', async t => {
         // tree is the same since whether or not the external icon links are
         // shown is dependent on a slot, which is undefined and arbitrary at
         // relations/data time (it might change on a whim at generate time).
-        linkExternalAsIcon: {
-          data: mock.function('linkExternalAsIcon.data', () => ({}))
+        generateExternalIcon: {
+          data: mock
+            .function('generateExternalIcon.data', () => ({}))
             .repeat(3),
 
-          generate: mock.function('linkExternalAsIcon.generate', () => 'icon')
+          generate: mock
+            .function('generateExternalIcon.generate', () => ({
+              toString: () => 'icon',
+              setSlot: () => {},
+            }))
             .repeat(3),
         },
       })),