diff --git a/src/index.js b/src/index.js index 4d07b90..a201264 100644 --- a/src/index.js +++ b/src/index.js @@ -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'), diff --git a/src/toBeGreaterThanOrEqualTo.js b/src/toBeGreaterThanOrEqualTo.js new file mode 100644 index 0000000..6efdc26 --- /dev/null +++ b/src/toBeGreaterThanOrEqualTo.js @@ -0,0 +1,9 @@ +'use strict'; + +var toBeNumber = require('./toBeNumber'); + +module.exports = toBeGreaterThanOrEqualTo; + +function toBeGreaterThanOrEqualTo(otherNumber, actual) { + return toBeNumber(actual) && actual >= otherNumber; +} diff --git a/test/toBeGreaterThanOrEqualTo.spec.js b/test/toBeGreaterThanOrEqualTo.spec.js new file mode 100644 index 0000000..80f9032 --- /dev/null +++ b/test/toBeGreaterThanOrEqualTo.spec.js @@ -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); + }); +});