diff options
Diffstat (limited to 'test/unit/data/composite/data/withPropertiesFromObject.js')
-rw-r--r-- | test/unit/data/composite/data/withPropertiesFromObject.js | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/test/unit/data/composite/data/withPropertiesFromObject.js b/test/unit/data/composite/data/withPropertiesFromObject.js index 750dc8c4..b81d51a5 100644 --- a/test/unit/data/composite/data/withPropertiesFromObject.js +++ b/test/unit/data/composite/data/withPropertiesFromObject.js @@ -1,4 +1,5 @@ import t from 'tap'; +import {quickCheckCompositeOutputs} from '#test-lib'; import {compositeFrom, input} from '#composite'; import {exposeDependency} from '#composite/control-flow'; @@ -62,6 +63,8 @@ t.test(`withPropertiesFromObject: output shapes & values`, t => { ['foo', 'baz', 'missing3'], }; + const qcco = quickCheckCompositeOutputs(t, dependencies); + const mapLevel1 = [ [input.value('prefix_value'), [ ['object_dependency', [ @@ -153,28 +156,10 @@ t.test(`withPropertiesFromObject: output shapes & values`, t => { properties: propertiesInput, }); - quickCheckOutputs(step, outputDict); + qcco(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); - } }); t.test(`withPropertiesFromObject: validate static inputs`, t => { @@ -226,11 +211,12 @@ t.test(`withPropertiesFromObject: validate dynamic inputs`, t => { properties: 'onceMore', }), {message: `Error computing composition`, cause: - {message: `Error computing composition withPropertiesFromObject`, cause: - {message: `Errors in input values provided to withPropertiesFromObject`, errors: [ - {message: `object: Expected an object, got string`}, - {message: `properties: Expected an array, got string`}, - ]}}}); + {message: `Error in step 1 of 2, withPropertiesFromObject`, cause: + {message: `Error computing composition withPropertiesFromObject`, cause: + {message: `Errors in input values provided to withPropertiesFromObject`, errors: [ + {message: `object: Expected an object, got string`}, + {message: `properties: Expected an array, got string`}, + ]}}}}); t.throws( () => composite.expose.compute({ @@ -238,17 +224,18 @@ t.test(`withPropertiesFromObject: validate dynamic inputs`, t => { properties: ['abc', 'def', 123], }), {message: `Error computing composition`, cause: - {message: `Error computing composition withPropertiesFromObject`, cause: - {message: `Errors in input values provided to withPropertiesFromObject`, errors: [ - {message: `object: Expected an object, got array`}, - {message: `properties: Errors validating array items`, errors: [ - { - [Symbol.for('hsmusic.annotateError.indexInSourceArray')]: 2, - message: `Error at zero-index 2: 123`, - cause: { - message: `Expected a string, got number`, + {message: `Error in step 1 of 2, withPropertiesFromObject`, cause: + {message: `Error computing composition withPropertiesFromObject`, cause: + {message: `Errors in input values provided to withPropertiesFromObject`, errors: [ + {message: `object: Expected an object, got array`}, + {message: `properties: Errors validating array items`, errors: [ + { + [Symbol.for('hsmusic.annotateError.indexInSourceArray')]: 2, + message: `Error at zero-index 2: 123`, + cause: { + message: `Expected a string, got number`, + }, }, - }, - ]}, - ]}}}); + ]}, + ]}}}}); }); |