Skip to content

Commit

Permalink
Issue #305 fixed, added assert.isAbove and assert.isBelow
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Jones committed Nov 29, 2014
1 parent ff32dad commit e8e8caf
Show file tree
Hide file tree
Showing 2 changed files with 60 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 @@ -237,6 +237,42 @@ module.exports = function (chai, util) {
* @api public
*/

assert.isAbove = function (val, abv, msg) {
new Assertion(val, msg).to.be.above(abv);
};

/**
* ### .isAbove(valueToCheck, valueToBeAbove, [message])
*
* Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`
*
* assert.isAbove(5, 2, '5 is strictly greater than 2');
*
* @name isAbove
* @param {Mixed} valueToCheck
* @param {Mixed} valueToBeAbove
* @param {String} message
* @api public
*/

assert.isBelow = function (val, blw, msg) {
new Assertion(val, msg).to.be.below(blw);
};

/**
* ### .isBelow(valueToCheck, valueToBeBelow, [message])
*
* Asserts `valueToCheck` is strictly less than (<) `valueToBeBelow`
*
* assert.isBelow(3, 6, '3 is strictly less than 6');
*
* @name isBelow
* @param {Mixed} valueToCheck
* @param {Mixed} valueToBeBelow
* @param {String} message
* @api public
*/

assert.isTrue = function (val, msg) {
new Assertion(val, msg).is['true'];
};
Expand Down
24 changes: 24 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,4 +651,28 @@ describe('assert', function () {
}, 'expected [ 1, 54 ] to have the same members as [ 6, 1, 54 ]');
});

it('above', function() {
assert.isAbove(5, 2, '5 should be above 2');

err(function() {
assert.isAbove(1, 3);
}, 'expected 1 to be above 3');

err(function() {
assert.isAbove(1, 1);
}, 'expected 1 to be above 1');
});

it('below', function() {
assert.isBelow(2, 5, '2 should be below 5');

err(function() {
assert.isBelow(3, 1);
}, 'expected 3 to be below 1');

err(function() {
assert.isBelow(1, 1);
}, 'expected 1 to be below 1');
});

});

0 comments on commit e8e8caf

Please sign in to comment.