« get me outta code hell

test: generateAlbumTrackList (snapshot, unit) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-24 17:41:24 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-24 17:41:24 -0300
commit324b74cef03ca5f21e938ed3bb9a43e564b377fa (patch)
tree9746b8d31739a379dd7a49effb06e09c3b9bd8a5 /test/unit
parent47d504251c084e601b946866e572519b2612b13c (diff)
test: generateAlbumTrackList (snapshot, unit)
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/content/dependencies/generateAlbumTrackList.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/content/dependencies/generateAlbumTrackList.js b/test/unit/content/dependencies/generateAlbumTrackList.js
new file mode 100644
index 00000000..80b086ca
--- /dev/null
+++ b/test/unit/content/dependencies/generateAlbumTrackList.js
@@ -0,0 +1,40 @@
+import t from 'tap';
+import {testContentFunctions} from '../../../lib/content-function.js';
+
+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}`),
+      },
+    },
+  });
+
+  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');
+});