« get me outta code hell

data, test: withResultOfAvailabilityCheck: index mode - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-26 19:05:39 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-26 19:36:59 -0300
commit5f740046562c85ab4e00063037ddf3af5a545279 (patch)
tree3581813e1af6f3446a3986d9381093bd1ea0cb20 /test/unit
parentecac8276182436897dffff02aaf1a7d268738cba (diff)
data, test: withResultOfAvailabilityCheck: index mode
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/data/composite/control-flow/withResultOfAvailabilityCheck.js32
1 files changed, 27 insertions, 5 deletions
diff --git a/test/unit/data/composite/control-flow/withResultOfAvailabilityCheck.js b/test/unit/data/composite/control-flow/withResultOfAvailabilityCheck.js
index 4c4be04..2bcabb4 100644
--- a/test/unit/data/composite/control-flow/withResultOfAvailabilityCheck.js
+++ b/test/unit/data/composite/control-flow/withResultOfAvailabilityCheck.js
@@ -38,7 +38,7 @@ const quickThrows = (t, {from, mode}) =>
   t.throws(() => composite.expose.compute({from, mode}));
 
 t.test(`withResultOfAvailabilityCheck: mode = null`, t => {
-  t.plan(10);
+  t.plan(11);
 
   quickCompare(t, true,  {mode: 'null', from: 'truthy string'});
   quickCompare(t, true,  {mode: 'null', from: 123});
@@ -46,6 +46,7 @@ t.test(`withResultOfAvailabilityCheck: mode = null`, t => {
 
   quickCompare(t, true,  {mode: 'null', from: ''});
   quickCompare(t, true,  {mode: 'null', from: 0});
+  quickCompare(t, true,  {mode: 'null', from: -1});
   quickCompare(t, true,  {mode: 'null', from: false});
 
   quickCompare(t, true,  {mode: 'null', from: [1, 2, 3]});
@@ -56,7 +57,7 @@ t.test(`withResultOfAvailabilityCheck: mode = null`, t => {
 });
 
 t.test(`withResultOfAvailabilityCheck: mode = empty`, t => {
-  t.plan(10);
+  t.plan(11);
 
   quickThrows(t, {mode: 'empty', from: 'truthy string'});
   quickThrows(t, {mode: 'empty', from: 123});
@@ -64,6 +65,7 @@ t.test(`withResultOfAvailabilityCheck: mode = empty`, t => {
 
   quickThrows(t, {mode: 'empty', from: ''});
   quickThrows(t, {mode: 'empty', from: 0});
+  quickThrows(t, {mode: 'empty', from: -1});
   quickThrows(t, {mode: 'empty', from: false});
 
   quickCompare(t, true,  {mode: 'empty', from: [1, 2, 3]});
@@ -74,7 +76,7 @@ t.test(`withResultOfAvailabilityCheck: mode = empty`, t => {
 });
 
 t.test(`withResultOfAvailabilityCheck: mode = falsy`, t => {
-  t.plan(10);
+  t.plan(11);
 
   quickCompare(t, true,  {mode: 'falsy', from: 'truthy string'});
   quickCompare(t, true,  {mode: 'falsy', from: 123});
@@ -82,6 +84,7 @@ t.test(`withResultOfAvailabilityCheck: mode = falsy`, t => {
 
   quickCompare(t, false, {mode: 'falsy', from: ''});
   quickCompare(t, false, {mode: 'falsy', from: 0});
+  quickCompare(t, true,  {mode: 'falsy', from: -1});
   quickCompare(t, false, {mode: 'falsy', from: false});
 
   quickCompare(t, true,  {mode: 'falsy', from: [1, 2, 3]});
@@ -91,6 +94,25 @@ t.test(`withResultOfAvailabilityCheck: mode = falsy`, t => {
   quickCompare(t, false, {mode: 'falsy', from: undefined});
 });
 
+t.test(`withResultOfAvailabilityCheck: mode = index`, t => {
+  t.plan(11);
+
+  quickCompare(t, false, {mode: 'index', from: 'truthy string'});
+  quickCompare(t, true,  {mode: 'index', from: 123});
+  quickCompare(t, false, {mode: 'index', from: true});
+
+  quickCompare(t, false, {mode: 'index', from: ''});
+  quickCompare(t, true,  {mode: 'index', from: 0});
+  quickCompare(t, false, {mode: 'index', from: -1});
+  quickCompare(t, false, {mode: 'index', from: false});
+
+  quickCompare(t, false, {mode: 'index', from: [1, 2, 3]});
+  quickCompare(t, false, {mode: 'index', from: []});
+
+  quickCompare(t, false, {mode: 'index', from: null});
+  quickCompare(t, false, {mode: 'index', from: undefined});
+});
+
 t.test(`withResultOfAvailabilityCheck: default mode`, t => {
   t.plan(1);
 
@@ -133,7 +155,7 @@ t.test(`withResultOfAvailabilityCheck: validate static inputs`, t => {
       mode: input.value('invalid'),
     }),
     {message: `Errors in input options passed to withResultOfAvailabilityCheck`, errors: [
-      {message: `mode: Expected one of null empty falsy, got invalid`},
+      {message: `mode: Expected one of null empty falsy index, got invalid`},
     ]});
 
   t.throws(() =>
@@ -157,7 +179,7 @@ t.test(`withResultOfAvailabilityCheck: validate dynamic inputs`, t => {
     {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: `mode: Expected one of null empty falsy index, got banana`},
         ]}}});
 
   t.throws(