diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-28 14:13:09 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-28 14:13:09 -0300 |
commit | ef290302472bd66ff9823aad1a4e029a4b4e2eba (patch) | |
tree | c45656c75fc156da8b5df2f95ef04f54cff84c39 /test/unit/data/composite/withResultOfAvailabilityCheck.js | |
parent | f7376bb5eb2671de7242872ec0c4615b5e244aba (diff) |
test: templateCompositeFrom (WIP), various composite test updates
Diffstat (limited to 'test/unit/data/composite/withResultOfAvailabilityCheck.js')
-rw-r--r-- | test/unit/data/composite/withResultOfAvailabilityCheck.js | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/test/unit/data/composite/withResultOfAvailabilityCheck.js b/test/unit/data/composite/withResultOfAvailabilityCheck.js index cac98d3c..01220a3a 100644 --- a/test/unit/data/composite/withResultOfAvailabilityCheck.js +++ b/test/unit/data/composite/withResultOfAvailabilityCheck.js @@ -110,8 +110,8 @@ t.test(`withResultOfAvailabilityCheck: default mode`, t => { }); }); -t.test(`withResultOfAvailabilityCheck: validate inputs`, t => { - t.plan(4); +t.test(`withResultOfAvailabilityCheck: validate static inputs`, t => { + t.plan(5); let caughtError; @@ -134,7 +134,7 @@ t.test(`withResultOfAvailabilityCheck: validate inputs`, t => { t.doesNotThrow(() => withResultOfAvailabilityCheck({ - from: input.value('static'), + from: input.value('some static value'), mode: input.value('null'), })); @@ -149,11 +149,78 @@ t.test(`withResultOfAvailabilityCheck: validate inputs`, t => { } t.match(caughtError, { + message: /Errors in input options passed to withResultOfAvailabilityCheck/, errors: [ - { - message: /mode: Validation failed for static value/, - cause: /Expected one of null empty falsy, got invalid/, - }, + /mode: Expected one of null empty falsy, got invalid/, ], }); + + try { + caughtError = null; + withResultOfAvailabilityCheck({ + from: input.value(null), + mode: input.value(null), + }); + } catch (error) { + caughtError = error; + } + + t.match(caughtError, { + message: /Errors in input options passed to withResultOfAvailabilityCheck/, + errors: [ + /mode: Expected value, got null/, + ], + }); +}); + +t.test(`withResultOfAvailabilityCheck: validate dynamic inputs`, t => { + t.plan(2); + + let caughtError; + + try { + caughtError = null; + composite.expose.compute({ + from: 'apple', + mode: 'banana', + }); + } catch (error) { + caughtError = error; + } + + t.match(caughtError, { + message: /Error computing composition/, + cause: { + message: /Error computing composition withResultOfAvailabilityCheck/, + cause: { + message: /Errors in input values provided to withResultOfAvailabilityCheck/, + errors: [ + /mode: Expected one of null empty falsy, got banana/, + ], + }, + }, + }); + + try { + caughtError = null; + composite.expose.compute({ + from: null, + mode: null, + }); + } catch (error) { + caughtError = error; + } + + t.match(caughtError, { + message: /Error computing composition/, + cause: { + message: /Error computing composition withResultOfAvailabilityCheck/, + cause: { + message: /Errors in input values provided to withResultOfAvailabilityCheck/, + errors: [ + /mode: Expected value, got null/, + ], + }, + }, + }); }); |