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

Added assert.notOk() #171

Merged
merged 2 commits into from
Jun 9, 2013
Merged
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
18 changes: 18 additions & 0 deletions lib/chai/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ module.exports = function (chai, util) {
new Assertion(val, msg).is.ok;
};

/**
* ### .notOk(object, [message])
*
* Asserts that `object` is falsy.
*
* assert.notOk('everything', 'this will fail');
* assert.notOk(false, 'this will pass');
*
* @name notOk
* @param {Mixed} object to test
* @param {String} message
* @api public
*/

assert.notOk = function (val, msg) {
new Assertion(val, msg).is.not.ok;
};

/**
* ### .equal(actual, expected, [message])
*
Expand Down
18 changes: 18 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ suite('assert', function () {
}, "expected '' to be truthy");
});

test('notOk', function () {
assert.notOk(false);
assert.notOk(0);
assert.notOk('');

err(function () {
assert.notOk(true);
}, "expected true to be falsy");

err(function () {
assert.notOk(1);
}, "expected 1 to be falsy");

err(function () {
assert.notOk('test');
}, "expected 'test' to be falsy");
});

test('isFalse', function () {
assert.isFalse(false);

Expand Down