« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/data-tests/test-no-short-tracks.js
diff options
context:
space:
mode:
Diffstat (limited to 'data-tests/test-no-short-tracks.js')
-rw-r--r--data-tests/test-no-short-tracks.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/data-tests/test-no-short-tracks.js b/data-tests/test-no-short-tracks.js
new file mode 100644
index 00000000..76356099
--- /dev/null
+++ b/data-tests/test-no-short-tracks.js
@@ -0,0 +1,25 @@
+export default function({
+  albumData,
+  getTotalDuration,
+}) {
+  const shortAlbums = albumData
+    .filter(album => album.tracks.length > 1)
+    .map(album => ({
+      album,
+      duration: getTotalDuration(album.tracks),
+    }))
+    .filter(album => album.duration)
+    .filter(album => album.duration < 60 * 15);
+
+  if (!shortAlbums.length) return true;
+
+  shortAlbums.sort((a, b) => a.duration - b.duration);
+
+  console.log(`Found ${shortAlbums.length} short albums! Oh nooooooo!`);
+  console.log(`Here are the shortest 10:`);
+  for (const {duration, album} of shortAlbums.slice(0, 10)) {
+    console.log(`- (${duration}s)`, album);
+  }
+
+  return false;
+}