@dmail/expect
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.expectUndefined = exports.expectNull = exports.expectFalse = exports.expectTrue = exports.expectNot = exports.matchNot = exports.matchExactly = exports.matchAny = exports.createExpectFromMatcherFactory = exports.createMatcher = exports.expectMatch = void 0; | ||
exports.expectUndefined = exports.expectNull = exports.expectFalse = exports.expectTrue = exports.expectNot = exports.matchNot = exports.matchExactly = exports.matchAny = exports.createExpectFromMatcherFactory = exports.createMatcher = exports.expectMatch = exports.isMatcher = void 0; | ||
@@ -21,3 +21,3 @@ var _action = require("@dmail/action"); | ||
var isMatcher = function isMatcher(value) { | ||
var isMatcher = exports.isMatcher = function isMatcher(value) { | ||
return value !== null && value !== undefined && value.hasOwnProperty(matchSymbol); | ||
@@ -24,0 +24,0 @@ }; |
@@ -141,2 +141,6 @@ "use strict"; | ||
return (0, _expectMatch.matchExactly)(value); | ||
} | ||
if ((0, _expectMatch.isMatcher)(value)) { | ||
return value; | ||
} // beware it can recurse indefinitely if the object structure is circular | ||
@@ -143,0 +147,0 @@ // like function with .prototype.constructor cycling back on the function |
@@ -174,4 +174,13 @@ "use strict"; | ||
pass(); | ||
}, | ||
"expectPropertiesDeep() with matcher": function expectPropertiesDeepWithMatcher(_ref18) { | ||
var pass = _ref18.pass; | ||
assertFailedWith((0, _expectProperties2.expectPropertiesDeep)({ | ||
age: 10 | ||
}, { | ||
age: (0, _expectBelow.matchBelow)(10) | ||
}), "age property mismatch: expect a number below 10 but got 10"); | ||
pass(); | ||
} | ||
}); | ||
//# sourceMappingURL=expectProperties.test.js.map |
{ | ||
"name": "@dmail/expect", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -12,3 +12,3 @@ // l'intérête principal de conserver un matcher et un expect séparé | ||
const matchSymbol = Symbol() | ||
const isMatcher = value => | ||
export const isMatcher = value => | ||
value !== null && value !== undefined && value.hasOwnProperty(matchSymbol) | ||
@@ -15,0 +15,0 @@ const match = (actual, expected) => { |
import { failed, all, any } from "@dmail/action" | ||
import { | ||
isMatcher, | ||
matchAny, | ||
@@ -120,2 +121,5 @@ matchExactly, | ||
} | ||
if (isMatcher(value)) { | ||
return value | ||
} | ||
// beware it can recurse indefinitely if the object structure is circular | ||
@@ -122,0 +126,0 @@ // like function with .prototype.constructor cycling back on the function |
@@ -120,3 +120,10 @@ import { | ||
pass() | ||
}, | ||
"expectPropertiesDeep() with matcher": ({ pass }) => { | ||
assertFailedWith( | ||
expectPropertiesDeep({ age: 10 }, { age: matchBelow(10) }), | ||
`age property mismatch: expect a number below 10 but got 10` | ||
) | ||
pass() | ||
} | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
259112
3771