« get me outta code hell

don't test content functions - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-03-31 19:38:31 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-03-31 19:38:31 -0300
commit33adddd56f07b60d390734b8a519238dc6c9469d (patch)
treeddf1eed04bdaad58efb91774da63ccf1b2b45ff7 /test/unit/content
parenta44f586bbc61bf8720770b59ece35b13b7bf0e62 (diff)
don't test content functions
Diffstat (limited to 'test/unit/content')
-rw-r--r--test/unit/content/dependencies/generateAlbumTrackList.js43
-rw-r--r--test/unit/content/dependencies/linkArtist.js31
-rw-r--r--test/unit/content/dependencies/linkContribution.js145
3 files changed, 0 insertions, 219 deletions
diff --git a/test/unit/content/dependencies/generateAlbumTrackList.js b/test/unit/content/dependencies/generateAlbumTrackList.js
deleted file mode 100644
index 988f8505..00000000
--- a/test/unit/content/dependencies/generateAlbumTrackList.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import t from 'tap';
-import {testContentFunctions} from '#test-lib';
-
-testContentFunctions(t, 'generateAlbumTrackList (unit)', async (t, evaluate) => {
-  await evaluate.load({
-    mock: {
-      generateAlbumTrackListItem: {
-        extraDependencies: ['html'],
-        data: track => track.name,
-        generate: (name, {html}) =>
-          html.tag('li', `Item: ${name}`),
-      },
-
-      image:
-        evaluate.stubContentFunction('image'),
-    },
-  });
-
-  let readDuration = false;
-
-  const track = (name, duration) => ({
-    name,
-    get duration() {
-      readDuration = true;
-      return duration;
-    },
-  });
-
-  const tracks = [
-    track('Track 1', 30),
-    track('Track 2', 15),
-  ];
-
-  evaluate({
-    name: 'generateAlbumTrackList',
-    args: [{
-      trackSections: [{isDefaultTrackSection: true, tracks}],
-      tracks,
-    }],
-  });
-
-  t.notOk(readDuration, 'expect no access to track.duration property');
-});
diff --git a/test/unit/content/dependencies/linkArtist.js b/test/unit/content/dependencies/linkArtist.js
deleted file mode 100644
index e6e19d2f..00000000
--- a/test/unit/content/dependencies/linkArtist.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import t from 'tap';
-import {testContentFunctions} from '#test-lib';
-
-testContentFunctions(t, 'linkArtist (unit)', async (t, evaluate) => {
-  const artistObject = {};
-  const linkTemplate = {};
-
-  await evaluate.load({
-    mock: evaluate.mock(mock => ({
-      linkThing: {
-        relations: mock.function('linkThing.relations', () => ({}))
-          .args([undefined, 'localized.artist', artistObject])
-          .once(),
-
-        data: mock.function('linkThing.data', () => ({}))
-          .args(['localized.artist', artistObject])
-          .once(),
-
-        generate: mock.function('linkThing.data', () => linkTemplate)
-          .once(),
-      }
-    })),
-  });
-
-  const result = evaluate({
-    name: 'linkArtist',
-    args: [artistObject],
-  });
-
-  t.equal(result, linkTemplate);
-});
diff --git a/test/unit/content/dependencies/linkContribution.js b/test/unit/content/dependencies/linkContribution.js
deleted file mode 100644
index 1baa80f8..00000000
--- a/test/unit/content/dependencies/linkContribution.js
+++ /dev/null
@@ -1,145 +0,0 @@
-import t from 'tap';
-import {testContentFunctions} from '#test-lib';
-
-t.test('linkContribution (unit)', async t => {
-  const artist1 = {
-    name: 'Clark Powell',
-    directory: 'clark-powell',
-    urls: ['https://soundcloud.com/plazmataz'],
-  };
-
-  const artist2 = {
-    name: 'Grounder & Scratch',
-    directory: 'the-big-baddies',
-    urls: [],
-  };
-
-  const artist3 = {
-    name: 'Toby Fox',
-    directory: 'toby-fox',
-    urls: ['https://tobyfox.bandcamp.com/', 'https://toby.fox/'],
-  };
-
-  const annotation1 = null;
-  const annotation2 = 'Snooping';
-  const annotation3 = 'Arrangement';
-
-  const thing1 = {};
-  const thing2 = {};
-  const thing3 = {};
-
-  const contribution1 = {artist: artist1, annotation: annotation1, thing: thing1};
-  const contribution2 = {artist: artist2, annotation: annotation2, thing: thing2};
-  const contribution3 = {artist: artist3, annotation: annotation3, thing: thing3};
-
-  await testContentFunctions(t, 'linkContribution (unit 1)', async (t, evaluate) => {
-    const slots = {
-      showAnnotation: true,
-      showExternalLinks: true,
-    };
-
-    await evaluate.load({
-      mock: evaluate.mock(mock => ({
-        linkArtist: {
-          relations: mock
-            .function('linkArtist.relations', () => ({}))
-            .args([undefined, artist1]).next()
-            .args([undefined, artist2]).next()
-            .args([undefined, artist3]),
-
-          data: mock
-            .function('linkArtist.data', () => ({}))
-            .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.
-          generate: mock.function('linkArtist.generate', () => 'artist link')
-            .repeat(3),
-        },
-
-        generateExternalIcon: {
-          data: mock
-            .function('generateExternalIcon.data', () => ({}))
-            .args([artist1.urls[0]]).next()
-            .args([artist3.urls[0]]).next()
-            .args([artist3.urls[1]]),
-
-          generate: mock
-            .function('generateExternalIcon.generate', () => ({
-              toString: () => 'icon',
-              setSlot: () => {},
-            }))
-            .repeat(3),
-        }
-      })),
-    });
-
-    evaluate({
-      name: 'linkContribution',
-      multiple: [
-        {args: [contribution1]},
-        {args: [contribution2]},
-        {args: [contribution3]},
-      ],
-      slots,
-    });
-  });
-
-  await testContentFunctions(t, 'linkContribution (unit 2)', async (t, evaluate) => {
-    const slots = {
-      showAnnotation: false,
-      showExternalLinks: false,
-    };
-
-    await evaluate.load({
-      mock: evaluate.mock(mock => ({
-        linkArtist: {
-          relations: mock
-            .function('linkArtist.relations', () => ({}))
-            .args([undefined, artist1]).next()
-            .args([undefined, artist2]).next()
-            .args([undefined, artist3]),
-
-          data: mock
-            .function('linkArtist.data', () => ({}))
-            .args([artist1]).next()
-            .args([artist2]).next()
-            .args([artist3]),
-
-          generate: mock
-            .function(() => 'artist link')
-            .repeat(3),
-        },
-
-        // Even though icons are hidden, these are still called! The dependency
-        // 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).
-        generateExternalIcon: {
-          data: mock
-            .function('generateExternalIcon.data', () => ({}))
-            .repeat(3),
-
-          generate: mock
-            .function('generateExternalIcon.generate', () => ({
-              toString: () => 'icon',
-              setSlot: () => {},
-            }))
-            .repeat(3),
-        },
-      })),
-    });
-
-    evaluate({
-      name: 'linkContribution',
-      multiple: [
-        {args: [contribution1]},
-        {args: [contribution2]},
-        {args: [contribution3]},
-      ],
-      slots,
-    });
-  });
-});