« get me outta code hell

test: linkExternal: match sort, write some testing guidelines - 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-03-30 10:28:17 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-03-30 10:29:08 -0300
commitebdc62e0bb57b2e9e0f81f2a8804940c76f007c8 (patch)
tree2468ac5fc4fcf23430649a98ef4a6d911d9ac085
parentb7f8d726125f6204e67393a02d5b42daaf814ee6 (diff)
test: linkExternal: match sort, write some testing guidelines
-rw-r--r--tap-snapshots/test/snapshot/linkExternal.js.test.cjs56
-rw-r--r--test/snapshot/linkExternal.js61
2 files changed, 74 insertions, 43 deletions
diff --git a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
index 824bec7b..e36ff75e 100644
--- a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
+++ b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
@@ -72,47 +72,47 @@ exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > context
 `
 
 exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > context: generic, style: handle 1`] = `
+<a href="https://music.solatrus.com/" class="nowrap">music.solatrus.com</a>
 <a href="https://homestuck.bandcamp.com/" class="nowrap">homestuck</a>
-<a href="https://soundcloud.com/plazmataz" class="nowrap">plazmataz</a>
-<a href="https://aeritus.tumblr.com/" class="nowrap">aeritus</a>
-<a href="https://twitter.com/awkwarddoesart" class="nowrap">awkwarddoesart</a>
 <a href="https://www.deviantart.com/chesswanderlust-sama" class="nowrap">DeviantArt</a>
-<a href="https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)" class="nowrap">Wikipedia</a>
-<a href="https://www.poetryfoundation.org/poets/christina-rossetti" class="nowrap">Poetry Foundation</a>
-<a href="https://www.instagram.com/levc_egm/" class="nowrap">Instagram</a>
-<a href="https://www.patreon.com/CecilyRenns" class="nowrap">CecilyRenns</a>
-<a href="https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3" class="nowrap">Spotify</a>
-<a href="https://buzinkai.newgrounds.com/" class="nowrap">buzinkai</a>
-<a href="https://music.solatrus.com/" class="nowrap">music.solatrus.com</a>
-<a href="https://types.pl/" class="nowrap">types.pl</a>
-<a href="https://community.fandom.com/" class="nowrap">Fandom</a>
-<a href="https://community.fandom.com/wiki/" class="nowrap">Fandom</a>
-<a href="https://community.fandom.com/wiki/Community_Central" class="nowrap">Fandom</a>
 <a href="https://mspaintadventures.fandom.com/" class="nowrap">MSPA Wiki</a>
 <a href="https://mspaintadventures.fandom.com/wiki/" class="nowrap">MSPA Wiki</a>
 <a href="https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary" class="nowrap">MSPA Wiki (Draconian Dignitary)</a>
+<a href="https://community.fandom.com/" class="nowrap">Fandom</a>
+<a href="https://community.fandom.com/wiki/" class="nowrap">Fandom</a>
+<a href="https://community.fandom.com/wiki/Community_Central" class="nowrap">Fandom</a>
+<a href="https://www.instagram.com/levc_egm/" class="nowrap">Instagram</a>
+<a href="https://types.pl/" class="nowrap">types.pl</a>
+<a href="https://buzinkai.newgrounds.com/" class="nowrap">buzinkai</a>
+<a href="https://www.patreon.com/CecilyRenns" class="nowrap">CecilyRenns</a>
+<a href="https://www.poetryfoundation.org/poets/christina-rossetti" class="nowrap">Poetry Foundation</a>
+<a href="https://soundcloud.com/plazmataz" class="nowrap">plazmataz</a>
+<a href="https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3" class="nowrap">Spotify</a>
+<a href="https://aeritus.tumblr.com/" class="nowrap">aeritus</a>
+<a href="https://twitter.com/awkwarddoesart" class="nowrap">awkwarddoesart</a>
+<a href="https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)" class="nowrap">Wikipedia</a>
 `
 
 exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > context: generic, style: platform 1`] = `
+<a href="https://music.solatrus.com/" class="nowrap">Bandcamp (music.solatrus.com)</a>
 <a href="https://homestuck.bandcamp.com/" class="nowrap">Bandcamp</a>
-<a href="https://soundcloud.com/plazmataz" class="nowrap">SoundCloud</a>
-<a href="https://aeritus.tumblr.com/" class="nowrap">Tumblr</a>
-<a href="https://twitter.com/awkwarddoesart" class="nowrap">Twitter</a>
 <a href="https://www.deviantart.com/chesswanderlust-sama" class="nowrap">DeviantArt</a>
-<a href="https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)" class="nowrap">Wikipedia</a>
-<a href="https://www.poetryfoundation.org/poets/christina-rossetti" class="nowrap">Poetry Foundation</a>
-<a href="https://www.instagram.com/levc_egm/" class="nowrap">Instagram</a>
-<a href="https://www.patreon.com/CecilyRenns" class="nowrap">Patreon</a>
-<a href="https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3" class="nowrap">Spotify</a>
-<a href="https://buzinkai.newgrounds.com/" class="nowrap">Newgrounds</a>
-<a href="https://music.solatrus.com/" class="nowrap">Bandcamp (music.solatrus.com)</a>
-<a href="https://types.pl/" class="nowrap">Mastodon (types.pl)</a>
-<a href="https://community.fandom.com/" class="nowrap">Fandom</a>
-<a href="https://community.fandom.com/wiki/" class="nowrap">Fandom</a>
-<a href="https://community.fandom.com/wiki/Community_Central" class="nowrap">Fandom</a>
 <a href="https://mspaintadventures.fandom.com/" class="nowrap">MSPA Wiki</a>
 <a href="https://mspaintadventures.fandom.com/wiki/" class="nowrap">MSPA Wiki</a>
 <a href="https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary" class="nowrap">MSPA Wiki (Draconian Dignitary)</a>
+<a href="https://community.fandom.com/" class="nowrap">Fandom</a>
+<a href="https://community.fandom.com/wiki/" class="nowrap">Fandom</a>
+<a href="https://community.fandom.com/wiki/Community_Central" class="nowrap">Fandom</a>
+<a href="https://www.instagram.com/levc_egm/" class="nowrap">Instagram</a>
+<a href="https://types.pl/" class="nowrap">Mastodon (types.pl)</a>
+<a href="https://buzinkai.newgrounds.com/" class="nowrap">Newgrounds</a>
+<a href="https://www.patreon.com/CecilyRenns" class="nowrap">Patreon</a>
+<a href="https://www.poetryfoundation.org/poets/christina-rossetti" class="nowrap">Poetry Foundation</a>
+<a href="https://soundcloud.com/plazmataz" class="nowrap">SoundCloud</a>
+<a href="https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3" class="nowrap">Spotify</a>
+<a href="https://aeritus.tumblr.com/" class="nowrap">Tumblr</a>
+<a href="https://twitter.com/awkwarddoesart" class="nowrap">Twitter</a>
+<a href="https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)" class="nowrap">Wikipedia</a>
 `
 
 exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > unknown domain (arbitrary world wide web path) 1`] = `
diff --git a/test/snapshot/linkExternal.js b/test/snapshot/linkExternal.js
index 6c43ea35..35af656b 100644
--- a/test/snapshot/linkExternal.js
+++ b/test/snapshot/linkExternal.js
@@ -26,29 +26,60 @@ testContentFunctions(t, 'linkExternal (snapshot)', async (t, evaluate) => {
     }
   };
 
+  // Try to comprehensively test every regular expression
+  // (in `match` and extractions like `handle` or `details`).
+
+  // For normal custom-domain matches (e.g. Mastodon),
+  // it's OK to just test one custom domain in the list.
+
+  // Generally match the sorting order in externalLinkSpec,
+  // so corresponding and missing test cases are easy to locate.
+
   quickSnapshotAllStyles('generic', [
+    // platform: bandcamp
+    'https://music.solatrus.com/',
     'https://homestuck.bandcamp.com/',
-    'https://soundcloud.com/plazmataz',
-    'https://aeritus.tumblr.com/',
-    'https://twitter.com/awkwarddoesart',
+
+    // platform: deviantart
     'https://www.deviantart.com/chesswanderlust-sama',
-    'https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)',
-    'https://www.poetryfoundation.org/poets/christina-rossetti',
+
+    // platform: fandom
+    'https://mspaintadventures.fandom.com/',
+    'https://mspaintadventures.fandom.com/wiki/',
+    'https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary',
+    'https://community.fandom.com/',
+    'https://community.fandom.com/wiki/',
+    'https://community.fandom.com/wiki/Community_Central',
+
+    // platform: instagram
     'https://www.instagram.com/levc_egm/',
+
+    // platform: mastodon
+    'https://types.pl/',
+
+    // platform: newgrounds
+    'https://buzinkai.newgrounds.com/',
+
+    // platform: patreon
     'https://www.patreon.com/CecilyRenns',
+
+    // platform: poetryFoundation
+    'https://www.poetryfoundation.org/poets/christina-rossetti',
+
+    // platform: soundcloud
+    'https://soundcloud.com/plazmataz',
+
+    // platform: spotify
     'https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3',
-    'https://buzinkai.newgrounds.com/',
 
-    // Just one custom domain of each platform is OK here
-    'https://music.solatrus.com/',
-    'https://types.pl/',
+    // platform: tumblr
+    'https://aeritus.tumblr.com/',
 
-    'https://community.fandom.com/',
-    'https://community.fandom.com/wiki/',
-    'https://community.fandom.com/wiki/Community_Central',
-    'https://mspaintadventures.fandom.com/',
-    'https://mspaintadventures.fandom.com/wiki/',
-    'https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary',
+    // platform: twitter
+    'https://twitter.com/awkwarddoesart',
+
+    // platform: wikipedia
+    'https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)',
   ]);
 
   quickSnapshotAllStyles('album', [