From: Chris Duncan Date: Thu, 3 Jul 2025 23:25:30 +0000 (-0700) Subject: Fix test assert definitions. X-Git-Tag: v0.10.5~134 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=939e8f0d1e7edd8dca5c2d8d09d500151768807d;p=libnemo.git Fix test assert definitions. --- diff --git a/test/GLOBALS.mjs b/test/GLOBALS.mjs index b02debc..14ab050 100644 --- a/test/GLOBALS.mjs +++ b/test/GLOBALS.mjs @@ -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()