]> git.codecow.com Git - libnemo.git/commitdiff
Fix test assert definitions.
authorChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 23:25:30 +0000 (16:25 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 23:25:30 +0000 (16:25 -0700)
test/GLOBALS.mjs

index b02debc6570c3d3bd7139c40e5178f069679364c..14ab050e9a706e05af98a1b033df092cb0179dab 100644 (file)
@@ -180,8 +180,7 @@ export const assert = {
        },
        exists: (a) => {
                if (a == null) {
-                       const type = /^[aeiou]/i.test(typeof a) ? `an ${typeof a}` : `a ${typeof a}`
-                       throw new Error(`argument exists and is ${type}`)
+                       throw new Error(`argument is ${typeof a}`)
                }
                return a != null
        },
@@ -203,6 +202,13 @@ export const assert = {
                }
                return a !== b
        },
+       nullish: (a) => {
+               if (a != null) {
+                       const type = /^[aeiou]/i.test(typeof a) ? `an ${typeof a}` : `a ${typeof a}`
+                       throw new Error(`argument exists and is ${type}`)
+               }
+               return a == null
+       },
        rejects: async (fn, msg) => {
                if (fn.constructor.name === 'AsyncFunction') {
                        fn = fn()