« get me outta code hell

composite.js « lib « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/lib/composite.js
blob: 359d364db082d2b1448171f2586d91be626f2271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {compositeFrom} from '#composite';

export function quickCheckCompositeOutputs(t, dependencies) {
  return (step, outputDict) => {
    t.same(
      Object.keys(step.toDescription().outputs),
      Object.keys(outputDict));

    const composite = compositeFrom({
      compose: false,
      steps: [
        step,

        {
          dependencies: Object.keys(outputDict),

          // Access all dependencies by their expected keys -
          // the composition runner actually provides a proxy
          // and is checking that *we* access the dependencies
          // we've specified.
          compute: dependencies =>
            Object.fromEntries(
              Object.keys(outputDict)
                .map(key => [key, dependencies[key]])),
        },
      ],
    });

    t.same(
      composite.expose.compute(dependencies),
      outputDict);
  };
}