Skip to content

Commit

Permalink
feat(numbers): add toBeGreaterThanOrEqualTo
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Aug 20, 2016
1 parent c5bc875 commit ac5da2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var matchers = {
toBeEvenNumber: require('./toBeEvenNumber'),
toBeFalse: require('./toBeFalse'),
toBeFunction: require('./toBeFunction'),
toBeGreaterThanOrEqualTo: require('./toBeGreaterThanOrEqualTo'),
toBeHtmlString: require('./toBeHtmlString'),
toBeIso8601: require('./toBeIso8601'),
toBeJsonString: require('./toBeJsonString'),
Expand Down
9 changes: 9 additions & 0 deletions src/toBeGreaterThanOrEqualTo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var toBeNumber = require('./toBeNumber');

module.exports = toBeGreaterThanOrEqualTo;

function toBeGreaterThanOrEqualTo(otherNumber, actual) {
return toBeNumber(actual) && actual >= otherNumber;
}
13 changes: 13 additions & 0 deletions test/toBeGreaterThanOrEqualTo.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

describe('toBeGreaterThanOrEqualTo', function () {
it('asserts value is greater or equal than a given number', function () {
expect(2).toBeGreaterThanOrEqualTo(1);
expect(1).toBeGreaterThanOrEqualTo(-1);
expect(-1).toBeGreaterThanOrEqualTo(-2);
expect(-2).toBeGreaterThanOrEqualTo(-2);
expect(NaN).not.toBeGreaterThanOrEqualTo(0);
expect(1).not.toBeGreaterThanOrEqualTo(2);
expect(-1).not.toBeGreaterThanOrEqualTo(0);
});
});

0 comments on commit ac5da2a

Please sign in to comment.