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.
- package/.eslintrc +15 -11
- package/dist/hamjest.js +6542 -23401
- package/dist/hamjest.min.js +1 -1
- package/gulpfile.js +0 -2
- package/index.js +95 -1
- package/lib/Description.js +32 -22
- package/lib/assertThat.js +4 -4
- package/lib/matchers/AllOf.js +8 -5
- package/lib/matchers/AnyOf.js +8 -8
- package/lib/matchers/DateComparisonMatcher.js +25 -24
- package/lib/matchers/Every.js +17 -11
- package/lib/matchers/FeatureMatcher.js +2 -2
- package/lib/matchers/Is.js +6 -5
- package/lib/matchers/IsAnything.js +2 -2
- package/lib/matchers/IsArray.js +4 -3
- package/lib/matchers/IsArrayContaining.js +8 -6
- package/lib/matchers/IsArrayContainingInAnyOrder.js +11 -8
- package/lib/matchers/IsArrayOrderedBy.js +5 -4
- package/lib/matchers/IsArrayWithItem.js +11 -8
- package/lib/matchers/IsArrayWithItems.js +6 -4
- package/lib/matchers/IsBoolean.js +4 -3
- package/lib/matchers/IsCloseTo.js +2 -2
- package/lib/matchers/IsDate.js +4 -3
- package/lib/matchers/IsDefined.js +4 -3
- package/lib/matchers/IsEqual.js +4 -3
- package/lib/matchers/IsFulfilled.js +2 -2
- package/lib/matchers/IsFunction.js +4 -3
- package/lib/matchers/IsFunctionThrowing.js +2 -2
- package/lib/matchers/IsInstanceOf.js +4 -3
- package/lib/matchers/IsNot.js +6 -5
- package/lib/matchers/IsNumber.js +4 -3
- package/lib/matchers/IsObject.js +4 -3
- package/lib/matchers/IsObjectWithProperties.js +19 -12
- package/lib/matchers/IsPromise.js +4 -3
- package/lib/matchers/IsRegExp.js +5 -6
- package/lib/matchers/IsRejected.js +2 -2
- package/lib/matchers/IsSame.js +2 -2
- package/lib/matchers/IsString.js +4 -3
- package/lib/matchers/IsStringMatching.js +2 -2
- package/lib/matchers/Matcher.js +10 -7
- package/lib/matchers/NumberComparisonMatcher.js +17 -16
- package/lib/matchers/SubstringMatcher.js +42 -39
- package/lib/matchers/failsToMatch.js +2 -2
- package/lib/matchers/falsy.js +2 -2
- package/lib/matchers/hasDescription.js +6 -5
- package/lib/matchers/hasExactlyOneItem.js +11 -8
- package/lib/matchers/hasSize.js +7 -4
- package/lib/matchers/inRange.js +11 -8
- package/lib/matchers/isEmpty.js +2 -2
- package/lib/matchers/matches.js +2 -2
- package/lib/matchers/promiseAgnostic.js +35 -15
- package/lib/matchers/returns.js +2 -2
- package/lib/matchers/truthy.js +2 -2
- package/lib/promiseThat.js +7 -9
- package/package.json +4 -5
- package/test/node/assertThatSpec.js +1 -3
- package/test/node/deferMatcher.js +2 -4
- package/test/node/esm/.eslintrc +5 -0
- package/test/node/esm/package.json +3 -0
- package/test/node/esm/providesNamedImports.js +3 -0
- package/test/node/matchers/AllOfSpec.js +1 -1
- package/test/node/matchers/AnyOfSpec.js +1 -1
- package/test/node/matchers/IsFulfilledSpec.js +29 -30
- package/test/node/matchers/IsPromiseSpec.js +3 -4
- package/test/node/matchers/IsRejectedSpec.js +21 -22
- package/test/node/promiseThatSpec.js +49 -86
- package/lib/hamjest.js +0 -106
- package/tags +0 -2855
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
|
+
const _every = require('lodash/every');
|
|
5
|
+
const _filter = require('lodash/filter');
|
|
4
6
|
const IsString = require('./IsString');
|
|
5
7
|
const assertThat = require('../assertThat');
|
|
6
8
|
const is = require('./Is').is;
|
|
@@ -9,7 +11,7 @@ const string = require('./IsString').string;
|
|
|
9
11
|
function SubstringMatcher(substring, relation, matchesString) {
|
|
10
12
|
assertThat(substring, is(string()));
|
|
11
13
|
|
|
12
|
-
return
|
|
14
|
+
return _create(new IsString(), {
|
|
13
15
|
matchesSafely(actual) {
|
|
14
16
|
return matchesString.call(this, actual);
|
|
15
17
|
},
|
|
@@ -30,42 +32,43 @@ function SubstringMatcher(substring, relation, matchesString) {
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
35
|
+
SubstringMatcher.containsString = function (substring) {
|
|
36
|
+
return new SubstringMatcher(substring, 'containing', (actualString) => {
|
|
37
|
+
return actualString.indexOf(substring) !== -1;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
SubstringMatcher.containsStrings = function (...substrings) {
|
|
42
|
+
substrings.map((s) => assertThat(s, is(string())));
|
|
43
|
+
return _create(new IsString(), {
|
|
44
|
+
matchesSafely(actual) {
|
|
45
|
+
return _every(substrings, (s) => actual.indexOf(s) !== -1);
|
|
46
|
+
},
|
|
47
|
+
describeTo(description) {
|
|
48
|
+
description
|
|
49
|
+
.append('a string containing ')
|
|
50
|
+
.appendList('', ', ', '', substrings);
|
|
51
|
+
},
|
|
52
|
+
describeMismatchSafely(actual, description) {
|
|
53
|
+
const notFound = _filter(substrings, (s) => actual.indexOf(s) === -1);
|
|
54
|
+
description
|
|
55
|
+
.appendList('', ', ', '', notFound)
|
|
56
|
+
.append(' could not be found in ')
|
|
57
|
+
.appendValue(actual);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
SubstringMatcher.startsWith = function (prefix) {
|
|
63
|
+
return new SubstringMatcher(prefix, 'starting with', (actualString) => {
|
|
64
|
+
return actualString.indexOf(prefix) === 0;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
SubstringMatcher.endsWith = function (suffix) {
|
|
69
|
+
return new SubstringMatcher(suffix, 'ending with', (actualString) => {
|
|
70
|
+
return actualString.indexOf(suffix, actualString.length - suffix.length) !== -1;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
70
73
|
|
|
71
74
|
module.exports = SubstringMatcher;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const Description = require('./../Description');
|
|
5
5
|
const TypeSafeMatcher = require('./TypeSafeMatcher');
|
|
6
6
|
const anything = require('./IsAnything').anything;
|
|
@@ -9,7 +9,7 @@ const isMatcher = require('./Matcher').isMatcher;
|
|
|
9
9
|
|
|
10
10
|
function failsToMatch(target, descriptionMatcher) {
|
|
11
11
|
descriptionMatcher = descriptionMatcher ? asMatcher(descriptionMatcher) : anything();
|
|
12
|
-
return
|
|
12
|
+
return _create(new TypeSafeMatcher(), {
|
|
13
13
|
isExpectedType: function (actual) {
|
|
14
14
|
return isMatcher(actual);
|
|
15
15
|
},
|
package/lib/matchers/falsy.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const Matcher = require('./Matcher');
|
|
5
5
|
|
|
6
6
|
function falsy() {
|
|
7
|
-
return
|
|
7
|
+
return _create(new Matcher(), {
|
|
8
8
|
matches: function (actualValue) {
|
|
9
9
|
return !actualValue;
|
|
10
10
|
},
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const Description = require('./../Description');
|
|
5
5
|
const TypeSafeMatcher = require('./TypeSafeMatcher');
|
|
6
|
-
const
|
|
6
|
+
const asMatcher = require('../utils/asMatcher');
|
|
7
7
|
const isMatcher = require('./Matcher').isMatcher;
|
|
8
8
|
|
|
9
|
-
module.exports =
|
|
10
|
-
|
|
9
|
+
module.exports = function (valueOrMatcher) {
|
|
10
|
+
const descriptionMatcher = asMatcher(valueOrMatcher);
|
|
11
|
+
return _create(new TypeSafeMatcher(), {
|
|
11
12
|
isExpectedType: function (actual) {
|
|
12
13
|
return isMatcher(actual);
|
|
13
14
|
},
|
|
@@ -29,4 +30,4 @@ module.exports = acceptingMatcher((descriptionMatcher) => {
|
|
|
29
30
|
descriptionMatcher.describeMismatch(actualDescription, description);
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
|
-
}
|
|
33
|
+
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
|
+
const _filter = require('lodash/filter');
|
|
5
|
+
const _map = require('lodash/map');
|
|
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
|
-
module.exports =
|
|
9
|
-
|
|
10
|
+
module.exports = function (valueOrMatcher) {
|
|
11
|
+
const matcher = asMatcher(valueOrMatcher);
|
|
12
|
+
return _create(new IsArray(), {
|
|
10
13
|
matchesSafely: function (actual) {
|
|
11
|
-
const results =
|
|
14
|
+
const results = _map(actual, (value) => {
|
|
12
15
|
return matcher.matches(value);
|
|
13
16
|
});
|
|
14
17
|
|
|
15
|
-
return promiseAgnostic.matchesAggregate(results, (results) =>
|
|
18
|
+
return promiseAgnostic.matchesAggregate(results, (results) => _filter(results).length === 1);
|
|
16
19
|
},
|
|
17
20
|
describeTo: function (description) {
|
|
18
21
|
description
|
|
@@ -24,7 +27,7 @@ module.exports = acceptingMatcher((matcher) => {
|
|
|
24
27
|
description.append('was empty');
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
|
-
const results =
|
|
30
|
+
const results = _map(actual, (value) => {
|
|
28
31
|
return matcher.matches(value);
|
|
29
32
|
});
|
|
30
33
|
|
|
@@ -67,4 +70,4 @@ module.exports = acceptingMatcher((matcher) => {
|
|
|
67
70
|
}));
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
|
-
}
|
|
73
|
+
};
|
package/lib/matchers/hasSize.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
|
+
const _isObject = require('lodash/isObject');
|
|
5
|
+
const _isString = require('lodash/isString');
|
|
6
|
+
const _size = require('lodash/size');
|
|
4
7
|
const TypeSafeMatcher = require('./TypeSafeMatcher');
|
|
5
8
|
const FeatureMatcher = require('./FeatureMatcher');
|
|
6
9
|
|
|
7
10
|
module.exports = function (valueOrMatcher) {
|
|
8
|
-
const innerMatcher = new FeatureMatcher(valueOrMatcher, 'a collection or string with size', 'size', (item) =>
|
|
9
|
-
return
|
|
11
|
+
const innerMatcher = new FeatureMatcher(valueOrMatcher, 'a collection or string with size', 'size', (item) => _size(item));
|
|
12
|
+
return _create(new TypeSafeMatcher(), {
|
|
10
13
|
isExpectedType: function (actual) {
|
|
11
|
-
return
|
|
14
|
+
return _isString(actual) || _isObject(actual);
|
|
12
15
|
},
|
|
13
16
|
matchesSafely: innerMatcher.matches,
|
|
14
17
|
describeTo: innerMatcher.describeTo,
|
package/lib/matchers/inRange.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
|
+
const _inRange = require('lodash/inRange');
|
|
5
|
+
const _isUndefined = require('lodash/isUndefined');
|
|
6
|
+
const assertThat = require('../assertThat');
|
|
7
|
+
const is = require('../matchers/Is').is;
|
|
8
|
+
const isNumber = require('../matchers/IsNumber').number;
|
|
4
9
|
|
|
5
10
|
module.exports = function (start, end) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (_.isUndefined(end)) {
|
|
11
|
+
if (_isUndefined(end)) {
|
|
9
12
|
end = start;
|
|
10
13
|
start = 0;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
assertThat('Start', start, is(isNumber()));
|
|
17
|
+
assertThat('End', end, is(isNumber()));
|
|
15
18
|
|
|
16
|
-
return
|
|
19
|
+
return _create(isNumber(), {
|
|
17
20
|
matchesSafely: function (actual) {
|
|
18
|
-
return
|
|
21
|
+
return _inRange(actual, start, end);
|
|
19
22
|
},
|
|
20
23
|
describeTo: function (description) {
|
|
21
24
|
description
|
package/lib/matchers/isEmpty.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _extend = require('lodash/extend');
|
|
4
4
|
const hasSize = require('./hasSize');
|
|
5
5
|
|
|
6
6
|
module.exports = function () {
|
|
7
|
-
return
|
|
7
|
+
return _extend(hasSize(0), {
|
|
8
8
|
describeTo: function (description) {
|
|
9
9
|
description.append('an empty collection or string');
|
|
10
10
|
}
|
package/lib/matchers/matches.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const Description = require('./../Description');
|
|
5
5
|
const TypeSafeMatcher = require('./TypeSafeMatcher');
|
|
6
6
|
const isMatcher = require('./Matcher').isMatcher;
|
|
7
7
|
|
|
8
8
|
function matches(target) {
|
|
9
|
-
return
|
|
9
|
+
return _create(new TypeSafeMatcher(), {
|
|
10
10
|
isExpectedType: function (actual) {
|
|
11
11
|
return isMatcher(actual);
|
|
12
12
|
},
|
|
@@ -1,41 +1,61 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const _forEach = require('lodash/forEach');
|
|
4
|
+
const _identity = require('lodash/identity');
|
|
5
|
+
const _isArray = require('lodash/isArray');
|
|
6
|
+
const _isFunction = require('lodash/isFunction');
|
|
7
|
+
const _reduce = require('lodash/reduce');
|
|
8
|
+
const _some = require('lodash/some');
|
|
5
9
|
|
|
6
10
|
function resolve(promises) {
|
|
7
|
-
if (
|
|
8
|
-
return
|
|
11
|
+
if (_isArray(promises)) {
|
|
12
|
+
return Promise.all(promises);
|
|
9
13
|
} else {
|
|
10
|
-
return
|
|
14
|
+
return Promise.resolve(promises)
|
|
15
|
+
.then((object) =>
|
|
16
|
+
Promise.all(
|
|
17
|
+
Object.entries(object).map(([key, value]) =>
|
|
18
|
+
Promise.resolve(value).then((value) => [key, value])
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
.then((items) => {
|
|
23
|
+
const results = {};
|
|
24
|
+
|
|
25
|
+
for (const [key, value] of items) {
|
|
26
|
+
results[key] = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return results;
|
|
30
|
+
});
|
|
11
31
|
}
|
|
12
32
|
}
|
|
13
33
|
|
|
14
34
|
const promiseAgnostic = {
|
|
15
35
|
matches: function (result, handler) {
|
|
16
36
|
if (isPromise(result)) {
|
|
17
|
-
return
|
|
37
|
+
return Promise.resolve(result).then(handler);
|
|
18
38
|
} else {
|
|
19
39
|
return handler(result);
|
|
20
40
|
}
|
|
21
41
|
},
|
|
22
42
|
matchesAggregate: function (results, handler) {
|
|
23
|
-
if (
|
|
43
|
+
if (_some(results, isPromise)) {
|
|
24
44
|
return resolve(results).then(handler);
|
|
25
45
|
} else {
|
|
26
46
|
return handler(results);
|
|
27
47
|
}
|
|
28
48
|
},
|
|
29
49
|
describeMismatchAggregate: function (results, handler, suffixFn) {
|
|
30
|
-
if (
|
|
50
|
+
if (_some(results, isPromise)) {
|
|
31
51
|
return resolve(results).then((results) => {
|
|
32
|
-
return
|
|
52
|
+
return _reduce(results, (chain, result, key) => {
|
|
33
53
|
return chain.then(() => handler(result, key));
|
|
34
|
-
},
|
|
54
|
+
}, Promise.resolve());
|
|
35
55
|
})
|
|
36
|
-
.then(suffixFn ||
|
|
56
|
+
.then(suffixFn || _identity);
|
|
37
57
|
} else {
|
|
38
|
-
|
|
58
|
+
_forEach(results, (result, key) => {
|
|
39
59
|
return handler(result, key);
|
|
40
60
|
});
|
|
41
61
|
if (suffixFn) {
|
|
@@ -45,9 +65,9 @@ const promiseAgnostic = {
|
|
|
45
65
|
},
|
|
46
66
|
describeMismatch: function (result, handler, suffixFn) {
|
|
47
67
|
if (isPromise(result)) {
|
|
48
|
-
return
|
|
68
|
+
return Promise.resolve(result)
|
|
49
69
|
.then(handler)
|
|
50
|
-
.then(suffixFn ||
|
|
70
|
+
.then(suffixFn || _identity);
|
|
51
71
|
} else {
|
|
52
72
|
handler(result);
|
|
53
73
|
if (suffixFn) {
|
|
@@ -58,7 +78,7 @@ const promiseAgnostic = {
|
|
|
58
78
|
};
|
|
59
79
|
|
|
60
80
|
function isPromise(value) {
|
|
61
|
-
return value &&
|
|
81
|
+
return value && _isFunction(value.then);
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
module.exports = promiseAgnostic;
|
package/lib/matchers/returns.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const anything = require('./IsAnything').anything;
|
|
5
5
|
const asMatcher = require('../utils/asMatcher');
|
|
6
6
|
const func = require('./IsFunction').func;
|
|
@@ -8,7 +8,7 @@ const getType = require('../utils/getType');
|
|
|
8
8
|
|
|
9
9
|
module.exports = function returns(resultValueOrMatcher) {
|
|
10
10
|
const resultMatcher = resultValueOrMatcher ? asMatcher(resultValueOrMatcher) : anything();
|
|
11
|
-
return
|
|
11
|
+
return _create(func(), {
|
|
12
12
|
matchesSafely: function (actual) {
|
|
13
13
|
try {
|
|
14
14
|
const result = actual();
|
package/lib/matchers/truthy.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _create = require('lodash/create');
|
|
4
4
|
const Matcher = require('./Matcher');
|
|
5
5
|
|
|
6
6
|
function truthy() {
|
|
7
|
-
return
|
|
7
|
+
return _create(new Matcher(), {
|
|
8
8
|
matches: function (actualValue) {
|
|
9
9
|
return !!actualValue;
|
|
10
10
|
},
|
package/lib/promiseThat.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _isFunction = require('lodash/isFunction');
|
|
4
4
|
const AssertionError = require('assertion-error');
|
|
5
|
-
const Bluebird = require('bluebird');
|
|
6
|
-
|
|
7
5
|
const Description = require('./Description');
|
|
8
6
|
|
|
9
7
|
function promiseThat(reason, actual, matcher) {
|
|
@@ -13,24 +11,24 @@ function promiseThat(reason, actual, matcher) {
|
|
|
13
11
|
reason = '';
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
return
|
|
14
|
+
return Promise.resolve().then(() => matcher.matches(actual)).then((result) => {
|
|
17
15
|
if (!result) {
|
|
18
16
|
const description = new Description();
|
|
19
17
|
description.append(reason)
|
|
20
18
|
.append('\nExpected: ')
|
|
21
19
|
.appendDescriptionOf(matcher)
|
|
22
20
|
.append('\n but: ');
|
|
23
|
-
return
|
|
21
|
+
return Promise.resolve().then(() => matcher.describeMismatch(actual, description))
|
|
24
22
|
.then(() => {
|
|
25
|
-
if (!
|
|
26
|
-
!
|
|
23
|
+
if (!_isFunction(matcher.getExpectedForDiff) ||
|
|
24
|
+
!_isFunction(matcher.formatActualForDiff)) {
|
|
27
25
|
return {};
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
return
|
|
28
|
+
return Promise.all([
|
|
31
29
|
matcher.getExpectedForDiff(),
|
|
32
30
|
matcher.formatActualForDiff(actual)
|
|
33
|
-
]).
|
|
31
|
+
]).then(([expected, actual]) => {
|
|
34
32
|
return {
|
|
35
33
|
showDiff: true,
|
|
36
34
|
expected: expected,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hamjest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "A library of composable matchers for defining meaningful and readable assertions in JavaScript.",
|
|
6
6
|
"homepage": "https://github.com/rluba/hamjest",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"assertion-error": "^1.1.0",
|
|
46
|
-
"bluebird": "^3.3.4",
|
|
47
46
|
"lodash": "^4.17.15"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
@@ -59,15 +58,15 @@
|
|
|
59
58
|
"eslint-config-leanbyte": "^2.0.0",
|
|
60
59
|
"gulp": "^4.0.2",
|
|
61
60
|
"gulp-eslint": "^6.0.0",
|
|
62
|
-
"gulp-mocha": "^
|
|
61
|
+
"gulp-mocha": "^8.0.0",
|
|
63
62
|
"gulp-rename": "^2.0.0",
|
|
64
63
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
65
64
|
"gulp-uglify": "^3.0.2",
|
|
66
|
-
"karma": "^
|
|
65
|
+
"karma": "^6.4.1",
|
|
67
66
|
"karma-chrome-launcher": "^3.0.0",
|
|
68
67
|
"karma-firefox-launcher": "^1.1.0",
|
|
69
68
|
"karma-mocha": "^2.0.1",
|
|
70
|
-
"mocha": "^
|
|
69
|
+
"mocha": "^10.2.0",
|
|
71
70
|
"typescript": "^3.8.3",
|
|
72
71
|
"vinyl-buffer": "^1.0.1",
|
|
73
72
|
"vinyl-source-stream": "^2.0.0"
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const assert = require('assert');
|
|
4
|
-
|
|
5
4
|
const AssertionError = require('assertion-error');
|
|
6
|
-
const Bluebird = require('bluebird');
|
|
7
5
|
|
|
8
6
|
const __ = require('../..');
|
|
9
7
|
const TestMatcher = require('./TestMatcher');
|
|
@@ -93,7 +91,7 @@ describe('assertThat', () => {
|
|
|
93
91
|
let thrown;
|
|
94
92
|
|
|
95
93
|
try {
|
|
96
|
-
__.assertThat('a value', new TestMatcher(() =>
|
|
94
|
+
__.assertThat('a value', new TestMatcher(() => Promise.resolve(true)));
|
|
97
95
|
} catch (e) {
|
|
98
96
|
thrown = e;
|
|
99
97
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Bluebird = require('bluebird');
|
|
4
|
-
|
|
5
3
|
function deferMatcher(matcher) {
|
|
6
4
|
return {
|
|
7
5
|
matches: function (actual) {
|
|
8
|
-
return
|
|
6
|
+
return Promise.resolve().then(() => matcher.matches(actual));
|
|
9
7
|
},
|
|
10
8
|
describeTo: function (description) {
|
|
11
9
|
description.append('deferred: ');
|
|
@@ -13,7 +11,7 @@ function deferMatcher(matcher) {
|
|
|
13
11
|
},
|
|
14
12
|
describeMismatch: function (actual, description) {
|
|
15
13
|
description.append('deferred: ');
|
|
16
|
-
return
|
|
14
|
+
return Promise.resolve().then(() => matcher.describeMismatch(actual, description));
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
17
|
}
|