Skip to content

Commit

Permalink
Merge pull request #494 from cezarykluczynski/assertions-is-not-false…
Browse files Browse the repository at this point in the history
…-is-not-true

isNotFalse, isNotTrue assertions added
  • Loading branch information
keithamus committed Jul 20, 2015
2 parents 4e18d2a + 5bd86c2 commit 3bd4d49
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/chai/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,24 @@ module.exports = function (chai, util) {
new Assertion(val, msg).is['true'];
};

/**
* ### .isNotTrue(value, [message])
*
* Asserts that `value` is not true.
*
* var tea = 'tasty chai';
* assert.isNotTrue(tea, 'great, time for tea!');
*
* @name isNotTrue
* @param {Mixed} value
* @param {String} message
* @api public
*/

assert.isNotTrue = function (val, msg) {
new Assertion(val, msg).to.not.equal(true);
};

/**
* ### .isFalse(value, [message])
*
Expand All @@ -297,6 +315,24 @@ module.exports = function (chai, util) {
new Assertion(val, msg).is['false'];
};

/**
* ### .isNotFalse(value, [message])
*
* Asserts that `value` is not false.
*
* var tea = 'tasty chai';
* assert.isNotFalse(tea, 'great, time for tea!');
*
* @name isNotFalse
* @param {Mixed} value
* @param {String} message
* @api public
*/

assert.isNotFalse = function (val, msg) {
new Assertion(val, msg).to.not.equal(false);
};

/**
* ### .isNull(value, [message])
*
Expand Down
16 changes: 16 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ describe('assert', function () {
}, "expected 'test' to be true");
});

it('isNotTrue', function () {
assert.isNotTrue(false);

err(function() {
assert.isNotTrue(true);
}, "expected true to not equal true");
});

it('isOk / ok', function () {
['isOk', 'ok'].forEach(function (isOk) {
assert[isOk](true);
Expand Down Expand Up @@ -88,6 +96,14 @@ describe('assert', function () {
}, "expected 0 to be false");
});

it('isNotFalse', function () {
assert.isNotFalse(true);

err(function() {
assert.isNotFalse(false);
}, "expected false to not equal false");
});

it('equal', function () {
var foo;
assert.equal(foo, undefined);
Expand Down

0 comments on commit 3bd4d49

Please sign in to comment.