hamjest 3.7.3 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.eslintrc +15 -11
  2. package/dist/hamjest.js +6542 -23401
  3. package/dist/hamjest.min.js +1 -1
  4. package/gulpfile.js +0 -2
  5. package/index.js +95 -1
  6. package/lib/Description.js +32 -22
  7. package/lib/assertThat.js +4 -4
  8. package/lib/matchers/AllOf.js +8 -5
  9. package/lib/matchers/AnyOf.js +8 -8
  10. package/lib/matchers/DateComparisonMatcher.js +25 -24
  11. package/lib/matchers/Every.js +17 -11
  12. package/lib/matchers/FeatureMatcher.js +2 -2
  13. package/lib/matchers/Is.js +6 -5
  14. package/lib/matchers/IsAnything.js +2 -2
  15. package/lib/matchers/IsArray.js +4 -3
  16. package/lib/matchers/IsArrayContaining.js +8 -6
  17. package/lib/matchers/IsArrayContainingInAnyOrder.js +11 -8
  18. package/lib/matchers/IsArrayOrderedBy.js +5 -4
  19. package/lib/matchers/IsArrayWithItem.js +11 -8
  20. package/lib/matchers/IsArrayWithItems.js +6 -4
  21. package/lib/matchers/IsBoolean.js +4 -3
  22. package/lib/matchers/IsCloseTo.js +2 -2
  23. package/lib/matchers/IsDate.js +4 -3
  24. package/lib/matchers/IsDefined.js +4 -3
  25. package/lib/matchers/IsEqual.js +4 -3
  26. package/lib/matchers/IsFulfilled.js +2 -2
  27. package/lib/matchers/IsFunction.js +4 -3
  28. package/lib/matchers/IsFunctionThrowing.js +2 -2
  29. package/lib/matchers/IsInstanceOf.js +4 -3
  30. package/lib/matchers/IsNot.js +6 -5
  31. package/lib/matchers/IsNumber.js +4 -3
  32. package/lib/matchers/IsObject.js +4 -3
  33. package/lib/matchers/IsObjectWithProperties.js +19 -12
  34. package/lib/matchers/IsPromise.js +4 -3
  35. package/lib/matchers/IsRegExp.js +5 -6
  36. package/lib/matchers/IsRejected.js +2 -2
  37. package/lib/matchers/IsSame.js +2 -2
  38. package/lib/matchers/IsString.js +4 -3
  39. package/lib/matchers/IsStringMatching.js +2 -2
  40. package/lib/matchers/Matcher.js +10 -7
  41. package/lib/matchers/NumberComparisonMatcher.js +17 -16
  42. package/lib/matchers/SubstringMatcher.js +42 -39
  43. package/lib/matchers/failsToMatch.js +2 -2
  44. package/lib/matchers/falsy.js +2 -2
  45. package/lib/matchers/hasDescription.js +6 -5
  46. package/lib/matchers/hasExactlyOneItem.js +11 -8
  47. package/lib/matchers/hasSize.js +7 -4
  48. package/lib/matchers/inRange.js +11 -8
  49. package/lib/matchers/isEmpty.js +2 -2
  50. package/lib/matchers/matches.js +2 -2
  51. package/lib/matchers/promiseAgnostic.js +35 -15
  52. package/lib/matchers/returns.js +2 -2
  53. package/lib/matchers/truthy.js +2 -2
  54. package/lib/promiseThat.js +7 -9
  55. package/package.json +4 -5
  56. package/test/node/assertThatSpec.js +1 -3
  57. package/test/node/deferMatcher.js +2 -4
  58. package/test/node/esm/.eslintrc +5 -0
  59. package/test/node/esm/package.json +3 -0
  60. package/test/node/esm/providesNamedImports.js +3 -0
  61. package/test/node/matchers/AllOfSpec.js +1 -1
  62. package/test/node/matchers/AnyOfSpec.js +1 -1
  63. package/test/node/matchers/IsFulfilledSpec.js +29 -30
  64. package/test/node/matchers/IsPromiseSpec.js +3 -4
  65. package/test/node/matchers/IsRejectedSpec.js +21 -22
  66. package/test/node/promiseThatSpec.js +49 -86
  67. package/lib/hamjest.js +0 -106
  68. package/tags +0 -2855
@@ -1,18 +1,21 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _map = require('lodash/map');
5
+ const _some = require('lodash/some');
4
6
  const IsArray = require('./IsArray');
5
- const acceptingMatcher = require('../utils/acceptingMatcher');
6
7
  const promiseAgnostic = require('./promiseAgnostic');
8
+ const asMatcher = require('../utils/asMatcher');
7
9
 
8
- const IsArrayWithItem = acceptingMatcher((matcher) => {
9
- return _.create(new IsArray(), {
10
+ function IsArrayWithItem(valueOrMatcher) {
11
+ const matcher = asMatcher(valueOrMatcher);
12
+ return _create(new IsArray(), {
10
13
  matchesSafely: function (actual) {
11
- const results = _.map(actual, (value) => {
14
+ const results = _map(actual, (value) => {
12
15
  return matcher.matches(value);
13
16
  });
14
17
 
15
- return promiseAgnostic.matchesAggregate(results, _.some);
18
+ return promiseAgnostic.matchesAggregate(results, _some);
16
19
  },
17
20
  describeTo: function (description) {
18
21
  description
@@ -24,7 +27,7 @@ const IsArrayWithItem = acceptingMatcher((matcher) => {
24
27
  description.append('was empty');
25
28
  return;
26
29
  }
27
- const results = _.map(actual, (value) => {
30
+ const results = _map(actual, (value) => {
28
31
  return matcher.matches(value);
29
32
  });
30
33
 
@@ -38,7 +41,7 @@ const IsArrayWithItem = acceptingMatcher((matcher) => {
38
41
  });
39
42
  }
40
43
  });
41
- });
44
+ }
42
45
 
43
46
  IsArrayWithItem.hasItem = function (valueOrMatcher) {
44
47
  return new IsArrayWithItem(valueOrMatcher);
@@ -1,14 +1,16 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _forEach = require('lodash/forEach');
5
+ const _map = require('lodash/map');
4
6
  const IsArray = require('./IsArray');
5
7
  const hasItem = require('./IsArrayWithItem').hasItem;
6
8
  const AllOf = require('./AllOf');
7
9
  const asMatcher = require('../utils/asMatcher');
8
10
 
9
11
  const IsArrayWithItems = function IsArrayWithItems(items) {
10
- const innerMatcher = new AllOf(_.map(items, hasItem));
11
- return _.create(new IsArray(), {
12
+ const innerMatcher = new AllOf(_map(items, hasItem));
13
+ return _create(new IsArray(), {
12
14
  matchesSafely: function (actual) {
13
15
  return innerMatcher.matches(actual);
14
16
  },
@@ -16,7 +18,7 @@ const IsArrayWithItems = function IsArrayWithItems(items) {
16
18
  description
17
19
  .append('an array containing ');
18
20
  let first = true;
19
- _.forEach(items, (item) => {
21
+ _forEach(items, (item) => {
20
22
  if (!first) {
21
23
  description.append(', ');
22
24
  }
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isBoolean = require('lodash/isBoolean');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsBoolean() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isBoolean(actual);
10
+ return _isBoolean(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsNumber = require('./IsNumber');
5
5
  const assertThat = require('../assertThat');
6
6
  const is = require('./Is').is;
@@ -14,7 +14,7 @@ function IsCloseTo(threshold, delta) {
14
14
  return Math.abs(actual - threshold);
15
15
  }
16
16
 
17
- return _.create(new IsNumber(), {
17
+ return _create(new IsNumber(), {
18
18
  matchesSafely: function (actual) {
19
19
  return getDelta(actual) <= delta;
20
20
  },
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isDate = require('lodash/isDate');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsDate() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isDate(actual);
10
+ return _isDate(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isUndefined = require('lodash/isUndefined');
4
5
  const Matcher = require('./Matcher');
5
6
  const not = require('./IsNot').not;
6
7
 
7
8
  function IsDefined() {
8
- return _.create(new Matcher(), {
9
+ return _create(new Matcher(), {
9
10
  matches: function (actual) {
10
- return !_.isUndefined(actual);
11
+ return !_isUndefined(actual);
11
12
  },
12
13
  describeTo: function (description) {
13
14
  description.append('defined');
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isEqual = require('lodash/isEqual');
4
5
  const Matcher = require('./Matcher');
5
6
 
6
7
  function IsEqual(expectedValue) {
7
- return _.create(new Matcher(), {
8
+ return _create(new Matcher(), {
8
9
  matches: function (actualValue) {
9
- return _.isEqual(expectedValue, actualValue);
10
+ return _isEqual(expectedValue, actualValue);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description.appendValue(expectedValue);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsPromise = require('./IsPromise');
5
5
  const asMatcher = require('../utils/asMatcher');
6
6
  const anything = require('./IsAnything').anything;
@@ -8,7 +8,7 @@ const anything = require('./IsAnything').anything;
8
8
  function IsFulfilled(valueOrMatcher) {
9
9
  const anyValue = (arguments.length === 0);
10
10
  const valueMatcher = (anyValue ? anything() : asMatcher(valueOrMatcher));
11
- return _.create(new IsPromise(), {
11
+ return _create(new IsPromise(), {
12
12
  matchesSafely: function (actual) {
13
13
  return actual.then((value) => {
14
14
  return valueMatcher.matches(value);
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isFunction = require('lodash/isFunction');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsFunction() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isFunction(actual);
10
+ return _isFunction(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsFunction = require('./IsFunction');
5
5
  const asMatcher = require('../utils/asMatcher');
6
6
  const anything = require('./IsAnything').anything;
@@ -8,7 +8,7 @@ const anything = require('./IsAnything').anything;
8
8
  function IsFunctionThrowing(valueOrMatcher) {
9
9
  const anyValue = (arguments.length === 0);
10
10
  const exceptionMatcher = (anyValue ? anything() : asMatcher(valueOrMatcher));
11
- return _.create(new IsFunction(), {
11
+ return _create(new IsFunction(), {
12
12
  matchesSafely: function (throwingFunction) {
13
13
  try {
14
14
  throwingFunction();
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isUndefined = require('lodash/isUndefined');
4
5
  const Matcher = require('./Matcher');
5
6
  const assertThat = require('../assertThat');
6
7
  const is = require('./Is').is;
@@ -11,7 +12,7 @@ const getTypeName = require('../utils/getTypeName');
11
12
  function IsInstanceOf(expectedType) {
12
13
  assertThat(expectedType, is(func()));
13
14
 
14
- return _.create(new Matcher(), {
15
+ return _create(new Matcher(), {
15
16
  matches: function (actual) {
16
17
  return actual instanceof expectedType;
17
18
  },
@@ -21,7 +22,7 @@ function IsInstanceOf(expectedType) {
21
22
  .append(getTypeName(expectedType));
22
23
  },
23
24
  describeMismatch: function (actual, description) {
24
- if (_.isUndefined(actual)) {
25
+ if (_isUndefined(actual)) {
25
26
  description
26
27
  .append('was ')
27
28
  .appendValue(actual);
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const Matcher = require('./Matcher');
5
- const acceptingMatcher = require('../utils/acceptingMatcher');
6
5
  const promiseAgnostic = require('./promiseAgnostic');
6
+ const asMatcher = require('../utils/asMatcher');
7
7
 
8
- const IsNot = acceptingMatcher((innerMatcher) => {
9
- return _.create(new Matcher(), {
8
+ function IsNot(valueOrMatcher) {
9
+ const innerMatcher = asMatcher(valueOrMatcher);
10
+ return _create(new Matcher(), {
10
11
  matches: function (actual) {
11
12
  return promiseAgnostic.matches(innerMatcher.matches(actual), (result) => {
12
13
  return !result;
@@ -23,7 +24,7 @@ const IsNot = acceptingMatcher((innerMatcher) => {
23
24
  .appendValue(value);
24
25
  }
25
26
  });
26
- });
27
+ }
27
28
 
28
29
  IsNot.not = function (innerMatcher) {
29
30
  return new IsNot(innerMatcher);
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isNumber = require('lodash/isNumber');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsNumber() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isNumber(actual);
10
+ return _isNumber(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isObject = require('lodash/isObject');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsObject() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isObject(actual);
10
+ return _isObject(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,6 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _every = require('lodash/every');
5
+ const _forEach = require('lodash/forEach');
6
+ const _isArray = require('lodash/isArray');
7
+ const _isUndefined = require('lodash/isUndefined');
8
+ const _map = require('lodash/map');
9
+ const _mapValues = require('lodash/mapValues');
10
+ const _reduceRight = require('lodash/reduceRight');
4
11
  const contains = require('./IsArrayContaining').contains;
5
12
  const IsObject = require('./IsObject');
6
13
  const isMatcher = require('./Matcher').isMatcher;
@@ -13,28 +20,28 @@ function asDeepMatcher(value) {
13
20
  if (value.constructor === Object || Object.getPrototypeOf(value) === null) {
14
21
  return new IsObjectWithProperties(value, true);
15
22
  }
16
- if (_.isArray(value)) {
17
- return contains(..._.map(value, v => asDeepMatcher(v)));
23
+ if (_isArray(value)) {
24
+ return contains(..._map(value, v => asDeepMatcher(v)));
18
25
  }
19
26
  }
20
27
  return asMatcher(value);
21
28
  }
22
29
 
23
30
  function IsObjectWithProperties(properties, deep = false) {
24
- const propertyMatchers = _.mapValues(properties, deep ? asDeepMatcher : asMatcher);
25
- return _.create(new IsObject(), {
31
+ const propertyMatchers = _mapValues(properties, deep ? asDeepMatcher : asMatcher);
32
+ return _create(new IsObject(), {
26
33
  matchesSafely: function (actual) {
27
- const results = _.mapValues(propertyMatchers, (matcher, key) => {
34
+ const results = _mapValues(propertyMatchers, (matcher, key) => {
28
35
  return matcher.matches(actual[key]);
29
36
  });
30
37
 
31
- return promiseAgnostic.matchesAggregate(results, _.every);
38
+ return promiseAgnostic.matchesAggregate(results, _every);
32
39
  },
33
40
  describeTo: function (description) {
34
41
  description.append('an object with {');
35
42
 
36
43
  let first = true;
37
- _.forEach(propertyMatchers, (matcher, key) => {
44
+ _forEach(propertyMatchers, (matcher, key) => {
38
45
  if (!first) {
39
46
  description.append(', ');
40
47
  }
@@ -49,7 +56,7 @@ function IsObjectWithProperties(properties, deep = false) {
49
56
  description.append('}');
50
57
  },
51
58
  describeMismatchSafely: function (actual, description) {
52
- const results = _.mapValues(propertyMatchers, (matcher, key) => {
59
+ const results = _mapValues(propertyMatchers, (matcher, key) => {
53
60
  return matcher.matches(actual[key]);
54
61
  });
55
62
 
@@ -91,10 +98,10 @@ IsObjectWithProperties.hasDeepProperties = function (properties) {
91
98
  };
92
99
 
93
100
  IsObjectWithProperties.hasProperty = function (propertyOrPath, valueOrMatcher) {
94
- const propertyPath = _.isArray(propertyOrPath) ? propertyOrPath : propertyOrPath.split('.');
101
+ const propertyPath = _isArray(propertyOrPath) ? propertyOrPath : propertyOrPath.split('.');
95
102
  const propertyToNestedMatcher = (matcher, prop) => new IsObjectWithProperties({[prop]: matcher});
96
- const initialMatcher = _.isUndefined(valueOrMatcher) ? defined() : valueOrMatcher;
97
- return _.reduceRight(propertyPath, propertyToNestedMatcher, initialMatcher);
103
+ const initialMatcher = _isUndefined(valueOrMatcher) ? defined() : valueOrMatcher;
104
+ return _reduceRight(propertyPath, propertyToNestedMatcher, initialMatcher);
98
105
  };
99
106
 
100
107
  module.exports = IsObjectWithProperties;
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isFunction = require('lodash/isFunction');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsPromise() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return actual && _.isFunction(actual.then);
10
+ return actual && _isFunction(actual.then);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,20 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _isRegExp = require('lodash/isRegExp');
4
4
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
5
 
6
6
  class IsRegExp extends TypeSafeMatcher {
7
7
  isExpectedType(actual) {
8
- return _.isRegExp(actual);
8
+ return _isRegExp(actual);
9
9
  }
10
10
  describeTo(description) {
11
11
  description
12
12
  .append('a regular expression');
13
13
  }
14
+ static regExp() {
15
+ return new IsRegExp();
16
+ }
14
17
  }
15
18
 
16
- IsRegExp.regExp = function () {
17
- return new IsRegExp();
18
- };
19
-
20
19
  module.exports = IsRegExp;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsPromise = require('./IsPromise');
5
5
  const asMatcher = require('../utils/asMatcher');
6
6
  const anything = require('./IsAnything').anything;
@@ -8,7 +8,7 @@ const anything = require('./IsAnything').anything;
8
8
  function IsRejected(valueOrMatcher) {
9
9
  const anyValue = (arguments.length === 0);
10
10
  const valueMatcher = (anyValue ? anything() : asMatcher(valueOrMatcher));
11
- return _.create(new IsPromise(), {
11
+ return _create(new IsPromise(), {
12
12
  matchesSafely: function (actual) {
13
13
  return actual.then(() => false, (reason) => {
14
14
  return valueMatcher.matches(reason);
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const Matcher = require('./Matcher');
5
5
 
6
6
  function IsSame(expectedValue) {
7
- return _.create(new Matcher(), {
7
+ return _create(new Matcher(), {
8
8
  matches: function (actualValue) {
9
9
  return expectedValue === actualValue;
10
10
  },
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
+ const _isString = require('lodash/isString');
4
5
  const TypeSafeMatcher = require('./TypeSafeMatcher');
5
6
 
6
7
  function IsString() {
7
- return _.create(new TypeSafeMatcher(), {
8
+ return _create(new TypeSafeMatcher(), {
8
9
  isExpectedType: function (actual) {
9
- return _.isString(actual);
10
+ return _isString(actual);
10
11
  },
11
12
  describeTo: function (description) {
12
13
  description
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsString = require('./IsString');
5
5
  const assertThat = require('../assertThat');
6
6
  const anyOf = require('./AnyOf').anyOf;
@@ -12,7 +12,7 @@ function IsStringMatching(stringOrPattern) {
12
12
 
13
13
  const pattern = new RegExp(stringOrPattern);
14
14
 
15
- return _.create(new IsString(), {
15
+ return _create(new IsString(), {
16
16
  matchesSafely: function (actual) {
17
17
  return pattern.test(actual);
18
18
  },
@@ -1,10 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _extend = require('lodash/extend');
4
+ const _isFunction = require('lodash/isFunction');
5
+ const _isNull = require('lodash/isNull');
6
+ const _isUndefined = require('lodash/isUndefined');
4
7
 
5
8
  class Matcher {
6
9
  constructor(fns = {}) {
7
- _.extend(this, fns);
10
+ _extend(this, fns);
8
11
  }
9
12
  matches() {
10
13
  throw new Error('Not implemented');
@@ -16,11 +19,11 @@ class Matcher {
16
19
  description.append('was ').appendValue(value);
17
20
  }
18
21
  static isMatcher(valueOrMatcher) {
19
- return !_.isUndefined(valueOrMatcher) &&
20
- !_.isNull(valueOrMatcher) &&
21
- _.isFunction(valueOrMatcher.matches) &&
22
- _.isFunction(valueOrMatcher.describeTo) &&
23
- _.isFunction(valueOrMatcher.describeMismatch);
22
+ return !_isUndefined(valueOrMatcher) &&
23
+ !_isNull(valueOrMatcher) &&
24
+ _isFunction(valueOrMatcher.matches) &&
25
+ _isFunction(valueOrMatcher.describeTo) &&
26
+ _isFunction(valueOrMatcher.describeMismatch);
24
27
  }
25
28
  }
26
29
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _ = require('lodash');
3
+ const _create = require('lodash/create');
4
4
  const IsNumber = require('./IsNumber');
5
5
  const assertThat = require('../assertThat');
6
6
  const is = require('./Is').is;
@@ -9,7 +9,7 @@ const number = require('./IsNumber').number;
9
9
  function NumberComparisonMatcher(relation, threshold, matchesNumber) {
10
10
  assertThat(threshold, is(number()));
11
11
 
12
- return _.create(new IsNumber(), {
12
+ return _create(new IsNumber(), {
13
13
  matchesSafely: function (actual) {
14
14
  return matchesNumber.call(this, actual);
15
15
  },
@@ -28,19 +28,20 @@ function NumberComparisonMatcher(relation, threshold, matchesNumber) {
28
28
  });
29
29
  }
30
30
 
31
- _.extend(NumberComparisonMatcher, {
32
- greaterThan: function (threshold) {
33
- return new NumberComparisonMatcher('greater than', threshold, (actual) => actual > threshold);
34
- },
35
- greaterThanOrEqualTo: function (threshold) {
36
- return new NumberComparisonMatcher('greater than or equal to', threshold, (actual) => actual >= threshold);
37
- },
38
- lessThan: function (threshold) {
39
- return new NumberComparisonMatcher('less than', threshold, (actual) => actual < threshold);
40
- },
41
- lessThanOrEqualTo: function (threshold) {
42
- return new NumberComparisonMatcher('less than or equal to', threshold, (actual) => actual <= threshold);
43
- }
44
- });
31
+ NumberComparisonMatcher.greaterThan = function (threshold) {
32
+ return new NumberComparisonMatcher('greater than', threshold, (actual) => actual > threshold);
33
+ };
34
+
35
+ NumberComparisonMatcher.greaterThanOrEqualTo = function (threshold) {
36
+ return new NumberComparisonMatcher('greater than or equal to', threshold, (actual) => actual >= threshold);
37
+ };
38
+
39
+ NumberComparisonMatcher.lessThan = function (threshold) {
40
+ return new NumberComparisonMatcher('less than', threshold, (actual) => actual < threshold);
41
+ };
42
+
43
+ NumberComparisonMatcher.lessThanOrEqualTo = function (threshold) {
44
+ return new NumberComparisonMatcher('less than or equal to', threshold, (actual) => actual <= threshold);
45
+ };
45
46
 
46
47
  module.exports = NumberComparisonMatcher;