Add aliases (and tests) for assert.ok and assert.notOk to match the other isSomething assertions

This commit is contained in:
Jérémie Astori 2015-07-18 22:41:26 +00:00
parent 40dc848842
commit 11aa743472
2 changed files with 34 additions and 26 deletions

View file

@ -72,6 +72,7 @@ module.exports = function (chai, util) {
* assert.ok(false, 'this will fail');
*
* @name ok
* @alias isOk
* @param {Mixed} object to test
* @param {String} message
* @api public
@ -90,6 +91,7 @@ module.exports = function (chai, util) {
* assert.notOk(false, 'this will pass');
*
* @name notOk
* @alias isNotOk
* @param {Mixed} object to test
* @param {String} message
* @api public
@ -1423,6 +1425,8 @@ module.exports = function (chai, util) {
assert[as] = assert[name];
return alias;
})
('ok', 'isOk')
('notOk', 'isNotOk')
('Throw', 'throw')
('Throw', 'throws')
('extensible', 'isExtensible')

View file

@ -36,40 +36,44 @@ describe('assert', function () {
}, "expected 'test' to be true");
});
it('ok', function () {
assert.ok(true);
assert.ok(1);
assert.ok('test');
it('isOk / ok', function () {
['isOk', 'ok'].forEach(function (isOk) {
assert[isOk](true);
assert[isOk](1);
assert[isOk]('test');
err(function () {
assert.ok(false);
}, "expected false to be truthy");
err(function () {
assert[isOk](false);
}, "expected false to be truthy");
err(function () {
assert.ok(0);
}, "expected 0 to be truthy");
err(function () {
assert[isOk](0);
}, "expected 0 to be truthy");
err(function () {
assert.ok('');
}, "expected '' to be truthy");
err(function () {
assert[isOk]('');
}, "expected '' to be truthy");
});
});
it('notOk', function () {
assert.notOk(false);
assert.notOk(0);
assert.notOk('');
it('isNotOk, notOk', function () {
['isNotOk', 'notOk'].forEach(function (isNotOk) {
assert[isNotOk](false);
assert[isNotOk](0);
assert[isNotOk]('');
err(function () {
assert.notOk(true);
}, "expected true to be falsy");
err(function () {
assert[isNotOk](true);
}, "expected true to be falsy");
err(function () {
assert.notOk(1);
}, "expected 1 to be falsy");
err(function () {
assert[isNotOk](1);
}, "expected 1 to be falsy");
err(function () {
assert.notOk('test');
}, "expected 'test' to be falsy");
err(function () {
assert[isNotOk]('test');
}, "expected 'test' to be falsy");
});
});
it('isFalse', function () {