Skip to content

Commit

Permalink
add truthy/falsy alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Mar 21, 2016
1 parent ad02c32 commit ce6a8a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])`

Expand Down
4 changes: 4 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ test('.ok()', function (t) {
assert.ok(true);
});

t.same(assert.ok, assert.truthy)

t.end();
});

Expand All @@ -44,6 +46,8 @@ test('.notOk()', function (t) {
assert.notOk(false);
});

t.same(assert.notOk, assert.falsy)

t.end();
});

Expand Down

0 comments on commit ce6a8a4

Please sign in to comment.