« get me outta code hell

data, test: refactor utilities into own file - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/composite/common-utilities/withPropertyFromObject.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-01 17:01:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-01 17:04:16 -0300
commitab7591e45e7e31b4e2c0e2f81e224672145993fa (patch)
tree11dcccc57e71424baa3b73a3eca58dabc56dca05 /test/unit/data/composite/common-utilities/withPropertyFromObject.js
parentdfcf911501211bbfc64b8ce6a964b70c6406447f (diff)
data, test: refactor utilities into own file
Primarily for more precies test coverage mapping, but also to make
navigation a bit easier and consolidate complex functions with
lots of imports out of the same space as other, more simple or
otherwise specialized files.
Diffstat (limited to 'test/unit/data/composite/common-utilities/withPropertyFromObject.js')
-rw-r--r--test/unit/data/composite/common-utilities/withPropertyFromObject.js125
1 files changed, 0 insertions, 125 deletions
diff --git a/test/unit/data/composite/common-utilities/withPropertyFromObject.js b/test/unit/data/composite/common-utilities/withPropertyFromObject.js
deleted file mode 100644
index 11487226..00000000
--- a/test/unit/data/composite/common-utilities/withPropertyFromObject.js
+++ /dev/null
@@ -1,125 +0,0 @@
-import t from 'tap';
-
-import {
-  compositeFrom,
-  exposeDependency,
-  input,
-  withPropertyFromObject,
-} from '#composite';
-
-t.test(`withPropertyFromObject: basic behavior`, t => {
-  t.plan(4);
-
-  const composite = compositeFrom({
-    compose: false,
-
-    steps: [
-      withPropertyFromObject({
-        object: 'object',
-        property: 'property',
-      }),
-
-      exposeDependency({dependency: '#value'}),
-    ],
-  });
-
-  t.match(composite, {
-    expose: {
-      dependencies: ['object', 'property'],
-    },
-  });
-
-  t.equal(composite.expose.compute({
-    object: {foo: 'bar', bim: 'BOOM'},
-    property: 'bim',
-  }), 'BOOM');
-
-  t.equal(composite.expose.compute({
-    object: {value1: 'uwah'},
-    property: 'value2',
-  }), null);
-
-  t.equal(composite.expose.compute({
-    object: null,
-    property: 'oml where did me object go',
-  }), null);
-});
-
-t.test(`withPropertyFromObject: output shapes & values`, t => {
-  t.plan(2 * 3 ** 2);
-
-  const dependencies = {
-    ['object_dependency']:
-      {foo: 'apple', bar: 'banana', baz: 'orange'},
-    [input('object_neither')]:
-      {foo: 'koala', bar: 'okapi', baz: 'mongoose'},
-    ['property_dependency']:
-      'foo',
-    [input('property_neither')]:
-      'baz',
-  };
-
-  const mapLevel1 = [
-    ['object_dependency', [
-      ['property_dependency', {
-        '#value': 'apple',
-      }],
-      [input.value('bar'), {
-        '#object_dependency.bar': 'banana',
-      }],
-      [input('property_neither'), {
-        '#value': 'orange',
-      }]]],
-
-    [input.value({foo: 'ouh', bar: 'rah', baz: 'nyu'}), [
-      ['property_dependency', {
-        '#value': 'ouh',
-      }],
-      [input.value('bar'), {
-        '#value': 'rah',
-      }],
-      [input('property_neither'), {
-        '#value': 'nyu',
-      }]]],
-
-    [input('object_neither'), [
-      ['property_dependency', {
-        '#value': 'koala',
-      }],
-      [input.value('bar'), {
-        '#value': 'okapi',
-      }],
-      [input('property_neither'), {
-        '#value': 'mongoose',
-      }]]],
-  ];
-
-  for (const [objectInput, mapLevel2] of mapLevel1) {
-    for (const [propertyInput, outputDict] of mapLevel2) {
-      const step = withPropertyFromObject({
-        object: objectInput,
-        property: propertyInput,
-      });
-
-      quickCheckOutputs(step, outputDict);
-    }
-  }
-
-  function quickCheckOutputs(step, outputDict) {
-    t.same(
-      Object.keys(step.toDescription().outputs),
-      Object.keys(outputDict));
-
-    const composite = compositeFrom({
-      compose: false,
-      steps: [step, {
-        dependencies: Object.keys(outputDict),
-        compute: dependencies => dependencies,
-      }],
-    });
-
-    t.same(
-      composite.expose.compute(dependencies),
-      outputDict);
-  }
-});