From 902ebbafb7cfb56f7a878d33cf94e5708861ff4a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Sep 2023 19:22:52 -0300 Subject: test: various error whitespace cleanup --- .../composite/common-utilities/exposeConstant.js | 18 +++---- .../composite/common-utilities/exposeDependency.js | 18 +++---- .../common-utilities/withPropertiesFromObject.js | 26 ++++----- .../withResultOfAvailabilityCheck.js | 63 +++++++--------------- test/unit/data/templateCompositeFrom.js | 29 ++++------ 5 files changed, 52 insertions(+), 102 deletions(-) diff --git a/test/unit/data/composite/common-utilities/exposeConstant.js b/test/unit/data/composite/common-utilities/exposeConstant.js index 829dc70..bfed095 100644 --- a/test/unit/data/composite/common-utilities/exposeConstant.js +++ b/test/unit/data/composite/common-utilities/exposeConstant.js @@ -34,19 +34,13 @@ t.test(`exposeConstant: validate inputs`, t => { t.throws( () => exposeConstant({}), - { - message: `Errors in input options passed to exposeConstant`, - errors: [ - {message: `Required these inputs: value`}, - ], - }); + {message: `Errors in input options passed to exposeConstant`, errors: [ + {message: `Required these inputs: value`}, + ]}); t.throws( () => exposeConstant({value: 'some dependency'}), - { - message: `Errors in input options passed to exposeConstant`, - errors: [ - {message: `value: Expected input.value() call, got dependency name`}, - ], - }); + {message: `Errors in input options passed to exposeConstant`, errors: [ + {message: `value: Expected input.value() call, got dependency name`}, + ]}); }); diff --git a/test/unit/data/composite/common-utilities/exposeDependency.js b/test/unit/data/composite/common-utilities/exposeDependency.js index 7880134..4f07cc1 100644 --- a/test/unit/data/composite/common-utilities/exposeDependency.js +++ b/test/unit/data/composite/common-utilities/exposeDependency.js @@ -54,21 +54,15 @@ t.test(`exposeDependency: validate inputs`, t => { t.throws( () => exposeDependency({}), - { - message: `Errors in input options passed to exposeDependency`, - errors: [ - {message: `Required these inputs: dependency`}, - ], - }); + {message: `Errors in input options passed to exposeDependency`, errors: [ + {message: `Required these inputs: dependency`}, + ]}); t.throws( () => exposeDependency({ dependency: input.value('some static value'), }), - { - message: `Errors in input options passed to exposeDependency`, - errors: [ - {message: `dependency: Expected dependency name, got input.value() call`}, - ], - }); + {message: `Errors in input options passed to exposeDependency`, errors: [ + {message: `dependency: Expected dependency name, got input.value() call`}, + ]}); }); diff --git a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js index b1b8be7..835767c 100644 --- a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js +++ b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js @@ -185,12 +185,9 @@ t.test(`withPropertiesFromObject: validate static inputs`, t => { t.throws( () => withPropertiesFromObject({}), - { - message: `Errors in input options passed to withPropertiesFromObject`, - errors: [ - {message: `Required these inputs: object, properties`}, - ], - }); + {message: `Errors in input options passed to withPropertiesFromObject`, errors: [ + {message: `Required these inputs: object, properties`}, + ]}); t.throws( () => withPropertiesFromObject({ @@ -198,14 +195,11 @@ t.test(`withPropertiesFromObject: validate static inputs`, t => { properties: input.value('very'), prefix: input.value({yes: 'yup'}), }), - { - message: `Errors in input options passed to withPropertiesFromObject`, - errors: [ - {message: `object: Expected an object, got string`}, - {message: 'properties: Expected an array, got string'}, - {message: 'prefix: Expected a string, got object'}, - ], - }); + {message: `Errors in input options passed to withPropertiesFromObject`, errors: [ + {message: `object: Expected an object, got string`}, + {message: `properties: Expected an array, got string`}, + {message: `prefix: Expected a string, got object`}, + ]}); t.throws( () => withPropertiesFromObject({ @@ -213,8 +207,8 @@ t.test(`withPropertiesFromObject: validate static inputs`, t => { properties: input.value(['abc', 'def', 123]), }), {message: `Errors in input options passed to withPropertiesFromObject`, errors: [ - {message: 'object: Expected an object, got array'}, - {message: 'properties: Errors validating array items', errors: [ + {message: `object: Expected an object, got array`}, + {message: `properties: Errors validating array items`, errors: [ { [Symbol.for('hsmusic.decorate.indexInSourceArray')]: 2, message: /Expected a string, got number/, diff --git a/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js b/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js index dacf60f..50c127d 100644 --- a/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js +++ b/test/unit/data/composite/common-utilities/withResultOfAvailabilityCheck.js @@ -3,8 +3,8 @@ import t from 'tap'; import { compositeFrom, continuationSymbol, - withResultOfAvailabilityCheck, input, + withResultOfAvailabilityCheck, } from '#composite'; const composite = compositeFrom({ @@ -115,12 +115,9 @@ t.test(`withResultOfAvailabilityCheck: validate static inputs`, t => { t.throws( () => withResultOfAvailabilityCheck({}), - { - message: `Errors in input options passed to withResultOfAvailabilityCheck`, - errors: [ - {message: `Required these inputs: from`} - ], - }); + {message: `Errors in input options passed to withResultOfAvailabilityCheck`, errors: [ + {message: `Required these inputs: from`}, + ]}); t.doesNotThrow(() => withResultOfAvailabilityCheck({ @@ -139,24 +136,18 @@ t.test(`withResultOfAvailabilityCheck: validate static inputs`, t => { from: 'foo', mode: input.value('invalid'), }), - { - message: `Errors in input options passed to withResultOfAvailabilityCheck`, - errors: [ - {message: `mode: Expected one of null empty falsy, got invalid`}, - ], - }); + {message: `Errors in input options passed to withResultOfAvailabilityCheck`, errors: [ + {message: `mode: Expected one of null empty falsy, got invalid`}, + ]}); t.throws(() => withResultOfAvailabilityCheck({ from: input.value(null), mode: input.value(null), }), - { - message: `Errors in input options passed to withResultOfAvailabilityCheck`, - errors: [ - {message: `mode: Expected a value, got null`}, - ], - }); + {message: `Errors in input options passed to withResultOfAvailabilityCheck`, errors: [ + {message: `mode: Expected a value, got null`}, + ]}); }); t.test(`withResultOfAvailabilityCheck: validate dynamic inputs`, t => { @@ -167,34 +158,20 @@ t.test(`withResultOfAvailabilityCheck: validate dynamic inputs`, t => { from: 'apple', mode: 'banana', }), - { - message: `Error computing composition`, - cause: { - message: `Error computing composition withResultOfAvailabilityCheck`, - cause: { - message: `Errors in input values provided to withResultOfAvailabilityCheck`, - errors: [ - {message: `mode: Expected one of null empty falsy, got banana`}, - ], - }, - }, - }); + {message: `Error computing composition`, cause: + {message: `Error computing composition withResultOfAvailabilityCheck`, cause: + {message: `Errors in input values provided to withResultOfAvailabilityCheck`, errors: [ + {message: `mode: Expected one of null empty falsy, got banana`}, + ]}}}); t.throws( () => composite.expose.compute({ from: null, mode: null, }), - { - message: `Error computing composition`, - cause: { - message: `Error computing composition withResultOfAvailabilityCheck`, - cause: { - message: `Errors in input values provided to withResultOfAvailabilityCheck`, - errors: [ - {message: `mode: Expected a value, got null`}, - ], - }, - }, - }); + {message: `Error computing composition`, cause: + {message: `Error computing composition withResultOfAvailabilityCheck`, cause: + {message: `Errors in input values provided to withResultOfAvailabilityCheck`, errors: [ + {message: `mode: Expected a value, got null`}, + ]}}}); }); diff --git a/test/unit/data/templateCompositeFrom.js b/test/unit/data/templateCompositeFrom.js index e96b782..2de1873 100644 --- a/test/unit/data/templateCompositeFrom.js +++ b/test/unit/data/templateCompositeFrom.js @@ -161,13 +161,10 @@ t.test(`templateCompositeFrom: validate static input values`, t => { baz: 'aeiou', raz: input.value(123), }), - { - message: `Errors in input options passed to stubComposite`, - errors: [ - {message: `Unexpected input names: baz, raz`}, - {message: `Required these inputs: foo, bar`}, - ], - }); + {message: `Errors in input options passed to stubComposite`, errors: [ + {message: `Unexpected input names: baz, raz`}, + {message: `Required these inputs: foo, bar`}, + ]}); }); t.test(`templateCompositeFrom: validate acceptsNull / defaultValue: null`, t => { @@ -181,12 +178,9 @@ t.test(`templateCompositeFrom: validate static input values`, t => { t.throws( () => template1({}), - { - message: `Errors in input options passed to stubComposite`, - errors: [ - {message: `Required these inputs: foo`}, - ], - }, + {message: `Errors in input options passed to stubComposite`, errors: [ + {message: `Required these inputs: foo`}, + ]}, `throws if input missing and not marked specially`); const template2 = templateCompositeFrom({ @@ -197,12 +191,9 @@ t.test(`templateCompositeFrom: validate static input values`, t => { t.throws( () => template2({}), - { - message: `Errors in input options passed to stubComposite`, - errors: [ - {message: `Required these inputs: bar`}, - ], - }, + {message: `Errors in input options passed to stubComposite`, errors: [ + {message: `Required these inputs: bar`}, + ]}, `throws if input missing even if marked {acceptsNull}`); const template3 = templateCompositeFrom({ -- cgit 1.3.0-6-gf8a5