isSameMomentAs function
Validates that a DateTime is the same moment as date
.
This matcher has additional behavior when used in expectResponse, hasResponse, hasHeaders, hasBody: if the actual value is a String, it will attempted to be parsed into a DateTime first. If parsing fails, this matcher will fail.
expectResponse(response, 200, headers: {"x-timestamp": isSameMomentAs(DateTime())});
Implementation
Matcher isSameMomentAs(DateTime date) {
return predicate(
(DateTime d) => d == date, "same moment as ${date.toIso8601String()}");
}