From 7f8c7f4c22cb717811bbfa331b7170f059fdbf8a Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 21 Mar 2016 13:15:54 -0600 Subject: [PATCH] add truthy/falsy alias --- lib/assert.js | 4 ++-- readme.md | 4 ++-- test/assert.js | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index f3d8c093b..802786e04 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -36,11 +36,11 @@ x.fail = function (msg) { test(false, create(false, false, 'fail', msg, x.fail)); }; -x.ok = function (val, msg) { +x.ok = x.truthy = function (val, msg) { test(val, create(val, true, '==', msg, x.ok)); }; -x.notOk = function (val, msg) { +x.notOk = x.falsy = function (val, msg) { test(!val, create(val, false, '==', msg, x.notOk)); }; diff --git a/readme.md b/readme.md index 8fcefdbe5..4729276e2 100644 --- a/readme.md +++ b/readme.md @@ -740,11 +740,11 @@ Failing assertion. ### `.ok(value, [message])` -Assert that `value` is truthy. +Assert that `value` is truthy. (Alias: `.truthy`) ### `.notOk(value, [message])` -Assert that `value` is falsy. +Assert that `value` is falsy. (Alias: `.falsy`) ### `.true(value, [message])` diff --git a/test/assert.js b/test/assert.js index c02b46d36..c51713e12 100644 --- a/test/assert.js +++ b/test/assert.js @@ -30,6 +30,8 @@ test('.ok()', function (t) { assert.ok(true); }); + t.same(assert.ok, assert.truthy); + t.end(); }); @@ -44,6 +46,8 @@ test('.notOk()', function (t) { assert.notOk(false); }); + t.same(assert.notOk, assert.falsy); + t.end(); });