From 0fc9972296f19c5da546861b9f3bb6d08c007d20 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 6 Dec 2022 17:02:50 -0400 Subject: quick-reload HSMusic-dedicated data tests --- test/data-tests/test-order-of-album-groups.js | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/data-tests/test-order-of-album-groups.js (limited to 'test/data-tests/test-order-of-album-groups.js') diff --git a/test/data-tests/test-order-of-album-groups.js b/test/data-tests/test-order-of-album-groups.js new file mode 100644 index 00000000..de2fcbed --- /dev/null +++ b/test/data-tests/test-order-of-album-groups.js @@ -0,0 +1,55 @@ +import * as util from 'util'; + +export default function({ + albumData, + groupCategoryData, +}) { + const groupSchemaTemplate = [ + ['Projects beyond Homestuck', 'Fandom projects'], + ['Solo musicians', 'Fan-musician groups'], + ['HSMusic'], + ]; + + const groupSchema = + groupSchemaTemplate.map(names => names.flatMap( + name => groupCategoryData + .find(gc => gc.name === name) + .groups)); + + const badAlbums = albumData.filter(album => { + const groups = album.groups.slice(); + const disallowed = []; + for (const allowed of groupSchema) { + while (groups.length) { + if (disallowed.includes(groups[0])) + return true; + else if (allowed.includes(groups[0])) + groups.shift(); + else break; + } + disallowed.push(...allowed); + } + return false; + }); + + if (!badAlbums.length) return true; + + console.log(`Some albums don't list their groups in the right order:`); + for (const album of badAlbums) { + console.log('-', album); + for (const group of album.groups) { + console.log(` - ${util.inspect(group)}`) + } + } + + console.log(`Here's the group schema they should be updated to match:`); + for (const section of groupSchemaTemplate) { + if (section.length > 1) { + console.log(`- Groups from any of: ${section.join(', ')}`); + } else { + console.log(`- Groups from: ${section}`); + } + } + + return false; +} -- cgit 1.3.0-6-gf8a5