« get me outta code hell

test: tidy output-checking syntax - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/composite
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-29 10:02:37 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-29 10:02:37 -0300
commitbc0f3fe427626bb3253c790898770f16701a512a (patch)
tree754ac82b04170a1d078efa8ceda8728aa86ac35b /test/unit/data/composite
parentb606bb424026597560144750d8dcf7b3e2601755 (diff)
test: tidy output-checking syntax
Diffstat (limited to 'test/unit/data/composite')
-rw-r--r--test/unit/data/composite/common-utilities/withPropertyFromObject.js41
1 files changed, 21 insertions, 20 deletions
diff --git a/test/unit/data/composite/common-utilities/withPropertyFromObject.js b/test/unit/data/composite/common-utilities/withPropertyFromObject.js
index c0e3dccf..11487226 100644
--- a/test/unit/data/composite/common-utilities/withPropertyFromObject.js
+++ b/test/unit/data/composite/common-utilities/withPropertyFromObject.js
@@ -46,7 +46,7 @@ t.test(`withPropertyFromObject: basic behavior`, t => {
 });
 
 t.test(`withPropertyFromObject: output shapes & values`, t => {
-  t.plan(3 * 3 * 2);
+  t.plan(2 * 3 ** 2);
 
   const dependencies = {
     ['object_dependency']:
@@ -59,7 +59,7 @@ t.test(`withPropertyFromObject: output shapes & values`, t => {
       'baz',
   };
 
-  const map = [
+  const mapLevel1 = [
     ['object_dependency', [
       ['property_dependency', {
         '#value': 'apple',
@@ -94,31 +94,32 @@ t.test(`withPropertyFromObject: output shapes & values`, t => {
       }]]],
   ];
 
-  for (const [objectInput, submap] of map) {
-    for (const [propertyInput, dict] of submap) {
+  for (const [objectInput, mapLevel2] of mapLevel1) {
+    for (const [propertyInput, outputDict] of mapLevel2) {
       const step = withPropertyFromObject({
         object: objectInput,
         property: propertyInput,
       });
 
-      t.same(
-        Object.keys(step.toDescription().outputs),
-        Object.keys(dict));
-
-      const composite = compositeFrom({
-        compose: false,
+      quickCheckOutputs(step, outputDict);
+    }
+  }
 
-        steps: [
-          step,
+  function quickCheckOutputs(step, outputDict) {
+    t.same(
+      Object.keys(step.toDescription().outputs),
+      Object.keys(outputDict));
 
-          {
-            dependencies: Object.keys(dict),
-            compute: dependencies => dependencies,
-          },
-        ],
-      });
+    const composite = compositeFrom({
+      compose: false,
+      steps: [step, {
+        dependencies: Object.keys(outputDict),
+        compute: dependencies => dependencies,
+      }],
+    });
 
-      t.same(composite.expose.compute(dependencies), dict);
-    }
+    t.same(
+      composite.expose.compute(dependencies),
+      outputDict);
   }
 });