hamjest
Version:
A library of composable matchers for defining meaningful and readable assertions in JavaScript.
22 lines (18 loc) • 514 B
JavaScript
;
const Bluebird = require('bluebird');
function deferMatcher(matcher) {
return {
matches: function (actual) {
return Bluebird.try(() => matcher.matches(actual));
},
describeTo: function (description) {
description.append('deferred: ');
matcher.describeTo(description);
},
describeMismatch: function (actual, description) {
description.append('deferred: ');
return Bluebird.try(() => matcher.describeMismatch(actual, description));
}
};
}
module.exports = deferMatcher;