Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add truthy/falsy alias #663

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that even in this very PR it is evident that I confused .same() with .is() :-)


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