Skip to content

Commit

Permalink
feat(numbers): add toBeLessThanOrEqualTo
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Aug 20, 2016
1 parent ac66a84 commit c5bc875
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 74 deletions.
149 changes: 75 additions & 74 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/toBeLessThanOrEqualTo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

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

module.exports = toBeLessThanOrEqualTo;

function toBeLessThanOrEqualTo(otherNumber, actual) {
return toBeNumber(actual) && actual <= otherNumber;
}
13 changes: 13 additions & 0 deletions test/toBeLessThanOrEqualTo.spec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit c5bc875

Please sign in to comment.