« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/composite/withResultOfAvailabilityCheck.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/data/composite/withResultOfAvailabilityCheck.js')
-rw-r--r--test/unit/data/composite/withResultOfAvailabilityCheck.js81
1 files changed, 74 insertions, 7 deletions
diff --git a/test/unit/data/composite/withResultOfAvailabilityCheck.js b/test/unit/data/composite/withResultOfAvailabilityCheck.js
index cac98d3..01220a3 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/,
+        ],
+      },
+    },
+  });
 });