diff --git a/src/index.js b/src/index.js index 32e70cb..4d07b90 100644 --- a/src/index.js +++ b/src/index.js @@ -28,80 +28,81 @@ var jasmineMatchers = require('jasmine-matchers-loader'); var matchers = { - toBeAfter: require('./toBeAfter'), - toBeArray: require('./toBeArray'), - toBeArrayOfBooleans: require('./toBeArrayOfBooleans'), - toBeArrayOfNumbers: require('./toBeArrayOfNumbers'), - toBeArrayOfObjects: require('./toBeArrayOfObjects'), - toBeArrayOfSize: require('./toBeArrayOfSize'), - toBeArrayOfStrings: require('./toBeArrayOfStrings'), - toBeBefore: require('./toBeBefore'), - toBeBoolean: require('./toBeBoolean'), - toBeCalculable: require('./toBeCalculable'), - toBeDate: require('./toBeDate'), - toBeEmptyArray: require('./toBeEmptyArray'), - toBeEmptyObject: require('./toBeEmptyObject'), - toBeEmptyString: require('./toBeEmptyString'), - toBeEvenNumber: require('./toBeEvenNumber'), - toBeFalse: require('./toBeFalse'), - toBeFunction: require('./toBeFunction'), - toBeHtmlString: require('./toBeHtmlString'), - toBeIso8601: require('./toBeIso8601'), - toBeJsonString: require('./toBeJsonString'), - toBeLongerThan: require('./toBeLongerThan'), - toBeNonEmptyArray: require('./toBeNonEmptyArray'), - toBeNonEmptyObject: require('./toBeNonEmptyObject'), - toBeNonEmptyString: require('./toBeNonEmptyString'), - toBeNumber: require('./toBeNumber'), - toBeObject: require('./toBeObject'), - toBeOddNumber: require('./toBeOddNumber'), - toBeSameLengthAs: require('./toBeSameLengthAs'), - toBeShorterThan: require('./toBeShorterThan'), - toBeString: require('./toBeString'), - toBeTrue: require('./toBeTrue'), - toBeWhitespace: require('./toBeWhitespace'), - toBeWholeNumber: require('./toBeWholeNumber'), - toBeWithinRange: require('./toBeWithinRange'), - toEndWith: require('./toEndWith'), - toImplement: require('./toImplement'), - toStartWith: require('./toStartWith'), - toThrowAnyError: require('./toThrowAnyError'), - toThrowErrorOfType: require('./toThrowErrorOfType'), - toHaveArray: require('./toHaveArray'), - toHaveArrayOfBooleans: require('./toHaveArrayOfBooleans'), - toHaveArrayOfNumbers: require('./toHaveArrayOfNumbers'), - toHaveArrayOfObjects: require('./toHaveArrayOfObjects'), - toHaveArrayOfSize: require('./toHaveArrayOfSize'), - toHaveArrayOfStrings: require('./toHaveArrayOfStrings'), - toHaveBoolean: require('./toHaveBoolean'), - toHaveCalculable: require('./toHaveCalculable'), - toHaveDate: require('./toHaveDate'), - toHaveDateAfter: require('./toHaveDateAfter'), - toHaveDateBefore: require('./toHaveDateBefore'), - toHaveEmptyArray: require('./toHaveEmptyArray'), - toHaveEmptyObject: require('./toHaveEmptyObject'), - toHaveEmptyString: require('./toHaveEmptyString'), - toHaveEvenNumber: require('./toHaveEvenNumber'), - toHaveFalse: require('./toHaveFalse'), - toHaveHtmlString: require('./toHaveHtmlString'), - toHaveIso8601: require('./toHaveIso8601'), - toHaveJsonString: require('./toHaveJsonString'), - toHaveMember: require('./toHaveMember'), - toHaveMethod: require('./toHaveMethod'), - toHaveNonEmptyArray: require('./toHaveNonEmptyArray'), - toHaveNonEmptyObject: require('./toHaveNonEmptyObject'), - toHaveNonEmptyString: require('./toHaveNonEmptyString'), - toHaveNumber: require('./toHaveNumber'), - toHaveNumberWithinRange: require('./toHaveNumberWithinRange'), - toHaveObject: require('./toHaveObject'), - toHaveOddNumber: require('./toHaveOddNumber'), - toHaveString: require('./toHaveString'), - toHaveStringLongerThan: require('./toHaveStringLongerThan'), - toHaveStringSameLengthAs: require('./toHaveStringSameLengthAs'), - toHaveStringShorterThan: require('./toHaveStringShorterThan'), - toHaveTrue: require('./toHaveTrue'), - toHaveWhitespaceString: require('./toHaveWhitespaceString'), - toHaveWholeNumber: require('./toHaveWholeNumber') + toBeAfter: require('./toBeAfter'), + toBeArray: require('./toBeArray'), + toBeArrayOfBooleans: require('./toBeArrayOfBooleans'), + toBeArrayOfNumbers: require('./toBeArrayOfNumbers'), + toBeArrayOfObjects: require('./toBeArrayOfObjects'), + toBeArrayOfSize: require('./toBeArrayOfSize'), + toBeArrayOfStrings: require('./toBeArrayOfStrings'), + toBeBefore: require('./toBeBefore'), + toBeBoolean: require('./toBeBoolean'), + toBeCalculable: require('./toBeCalculable'), + toBeDate: require('./toBeDate'), + toBeEmptyArray: require('./toBeEmptyArray'), + toBeEmptyObject: require('./toBeEmptyObject'), + toBeEmptyString: require('./toBeEmptyString'), + toBeEvenNumber: require('./toBeEvenNumber'), + toBeFalse: require('./toBeFalse'), + toBeFunction: require('./toBeFunction'), + toBeHtmlString: require('./toBeHtmlString'), + toBeIso8601: require('./toBeIso8601'), + toBeJsonString: require('./toBeJsonString'), + toBeLessThanOrEqualTo: require('./toBeLessThanOrEqualTo'), + toBeLongerThan: require('./toBeLongerThan'), + toBeNonEmptyArray: require('./toBeNonEmptyArray'), + toBeNonEmptyObject: require('./toBeNonEmptyObject'), + toBeNonEmptyString: require('./toBeNonEmptyString'), + toBeNumber: require('./toBeNumber'), + toBeObject: require('./toBeObject'), + toBeOddNumber: require('./toBeOddNumber'), + toBeSameLengthAs: require('./toBeSameLengthAs'), + toBeShorterThan: require('./toBeShorterThan'), + toBeString: require('./toBeString'), + toBeTrue: require('./toBeTrue'), + toBeWhitespace: require('./toBeWhitespace'), + toBeWholeNumber: require('./toBeWholeNumber'), + toBeWithinRange: require('./toBeWithinRange'), + toEndWith: require('./toEndWith'), + toHaveArray: require('./toHaveArray'), + toHaveArrayOfBooleans: require('./toHaveArrayOfBooleans'), + toHaveArrayOfNumbers: require('./toHaveArrayOfNumbers'), + toHaveArrayOfObjects: require('./toHaveArrayOfObjects'), + toHaveArrayOfSize: require('./toHaveArrayOfSize'), + toHaveArrayOfStrings: require('./toHaveArrayOfStrings'), + toHaveBoolean: require('./toHaveBoolean'), + toHaveCalculable: require('./toHaveCalculable'), + toHaveDate: require('./toHaveDate'), + toHaveDateAfter: require('./toHaveDateAfter'), + toHaveDateBefore: require('./toHaveDateBefore'), + toHaveEmptyArray: require('./toHaveEmptyArray'), + toHaveEmptyObject: require('./toHaveEmptyObject'), + toHaveEmptyString: require('./toHaveEmptyString'), + toHaveEvenNumber: require('./toHaveEvenNumber'), + toHaveFalse: require('./toHaveFalse'), + toHaveHtmlString: require('./toHaveHtmlString'), + toHaveIso8601: require('./toHaveIso8601'), + toHaveJsonString: require('./toHaveJsonString'), + toHaveMember: require('./toHaveMember'), + toHaveMethod: require('./toHaveMethod'), + toHaveNonEmptyArray: require('./toHaveNonEmptyArray'), + toHaveNonEmptyObject: require('./toHaveNonEmptyObject'), + toHaveNonEmptyString: require('./toHaveNonEmptyString'), + toHaveNumber: require('./toHaveNumber'), + toHaveNumberWithinRange: require('./toHaveNumberWithinRange'), + toHaveObject: require('./toHaveObject'), + toHaveOddNumber: require('./toHaveOddNumber'), + toHaveString: require('./toHaveString'), + toHaveStringLongerThan: require('./toHaveStringLongerThan'), + toHaveStringSameLengthAs: require('./toHaveStringSameLengthAs'), + toHaveStringShorterThan: require('./toHaveStringShorterThan'), + toHaveTrue: require('./toHaveTrue'), + toHaveWhitespaceString: require('./toHaveWhitespaceString'), + toHaveWholeNumber: require('./toHaveWholeNumber'), + toImplement: require('./toImplement'), + toStartWith: require('./toStartWith'), + toThrowAnyError: require('./toThrowAnyError'), + toThrowErrorOfType: require('./toThrowErrorOfType') }; jasmineMatchers.add(matchers); diff --git a/src/toBeLessThanOrEqualTo.js b/src/toBeLessThanOrEqualTo.js new file mode 100644 index 0000000..1ad0bef --- /dev/null +++ b/src/toBeLessThanOrEqualTo.js @@ -0,0 +1,9 @@ +'use strict'; + +var toBeNumber = require('./toBeNumber'); + +module.exports = toBeLessThanOrEqualTo; + +function toBeLessThanOrEqualTo(otherNumber, actual) { + return toBeNumber(actual) && actual <= otherNumber; +} diff --git a/test/toBeLessThanOrEqualTo.spec.js b/test/toBeLessThanOrEqualTo.spec.js new file mode 100644 index 0000000..ecfec8b --- /dev/null +++ b/test/toBeLessThanOrEqualTo.spec.js @@ -0,0 +1,13 @@ +'use strict'; + +describe('toBeLessThanOrEqualTo', function () { + it('asserts value is less or equal than a given number', function () { + expect(1).toBeLessThanOrEqualTo(2); + expect(-1).toBeLessThanOrEqualTo(1); + expect(-2).toBeLessThanOrEqualTo(-1); + expect(-2).toBeLessThanOrEqualTo(-2); + expect(NaN).not.toBeLessThanOrEqualTo(0); + expect(2).not.toBeLessThanOrEqualTo(1); + expect(0).not.toBeLessThanOrEqualTo(-1); + }); +});