« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/lib/content-function.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/content-function.js')
-rw-r--r--test/lib/content-function.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/lib/content-function.js b/test/lib/content-function.js
index bb12be82..b706cd8c 100644
--- a/test/lib/content-function.js
+++ b/test/lib/content-function.js
@@ -1,5 +1,6 @@
 import * as path from 'node:path';
 import {fileURLToPath} from 'node:url';
+import {inspect} from 'node:util';
 
 import chroma from 'chroma-js';
 
@@ -99,7 +100,7 @@ export function testContentFunctions(t, message, fn) {
 
         constructor() {
           super({
-            content: () => `${name}: ${JSON.stringify(this.#slotValues)}`,
+            content: () => this.#getContent(this),
           });
         }
 
@@ -110,6 +111,24 @@ export function testContentFunctions(t, message, fn) {
         setSlot(slotName, slotValue) {
           this.#slotValues[slotName] = slotValue;
         }
+
+        #getContent() {
+          const toInspect =
+            Object.fromEntries(
+              Object.entries(this.#slotValues)
+                .filter(([key, value]) => value !== null));
+
+          const inspected =
+            inspect(toInspect, {
+              breakLength: Infinity,
+              colors: false,
+              compact: true,
+              depth: Infinity,
+              sort: true,
+            });
+
+          return `${name}: ${inspected}`;
+        }
       });
     };