import assert from 'node:assert/strict' import { test } from 'node:test' import { resolveReplyText } from './decide-reply.ts' test('decide reply: true posts the reason, a string posts itself, false/blank posts nothing', () => { const reason = 'Builtins are resolved by nodejs_compat; intentional.' assert.equal(resolveReplyText(true, reason, 'x'), reason) assert.equal(resolveReplyText(' Custom reply. ', reason, 'x'), 'Custom reply.') assert.equal(resolveReplyText(false, reason, 'x'), undefined) assert.equal(resolveReplyText(undefined, reason, 'x'), undefined) assert.equal(resolveReplyText(null, reason, 'x'), undefined) assert.equal(resolveReplyText(' ', reason, 'x'), undefined) assert.throws(() => resolveReplyText(1, reason, 'x'), /reply must be true \(post the reason\) or a string/) })