diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-30 08:29:13 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-30 08:29:13 -0300 |
commit | 13b25a8d48d142b60d5c351aad4ad1bf80104320 (patch) | |
tree | c77d7c24a962aea5f14cf6da8bc222e8394cab23 /test/unit/data/composite/common-utilities | |
parent | 38e8ed330aa238dc258b7749ce704eb98f5ac670 (diff) |
util, test: WIP decorate error with index symbol
Diffstat (limited to 'test/unit/data/composite/common-utilities')
-rw-r--r-- | test/unit/data/composite/common-utilities/withPropertiesFromObject.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js index 9bcb84c3..6b4e10c4 100644 --- a/test/unit/data/composite/common-utilities/withPropertiesFromObject.js +++ b/test/unit/data/composite/common-utilities/withPropertiesFromObject.js @@ -179,3 +179,46 @@ t.test(`withPropertiesFromObject: output shapes & values`, t => { outputDict); } }); + +t.test(`withPropertiesFromObject: validate static inputs`, t => { + t.plan(3); + + t.throws( + () => withPropertiesFromObject({}), + { + message: `Errors in input options passed to withPropertiesFromObject`, + errors: [ + {message: `Required these inputs: object, properties`}, + ], + }); + + t.throws( + () => withPropertiesFromObject({ + object: input.value('intriguing'), + 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'}, + ], + }); + + t.throws( + () => withPropertiesFromObject({ + object: input.value([['abc', 1], ['def', 2], [123, 3]]), + 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: [ + { + [Symbol.for('hsmusic.sugar.index')]: 2, + message: /Expected a string, got number/, + }, + ]}, + ]}); +}); |