fix(assertion-matchers): Refactor matcher implementations to consistently use customAssertion for improved consistency and clarity.

This commit is contained in:
2025-04-28 19:58:32 +00:00
parent 4eac4544a5
commit 91a3dc43d3
11 changed files with 265 additions and 43 deletions

View File

@ -7,14 +7,23 @@ export class DateMatchers {
constructor(private assertion: Assertion<Date>) {}
toBeDate() {
return this.assertion.toBeDate();
return this.assertion.customAssertion(
(v) => v instanceof Date,
`Expected value to be a Date instance`
);
}
toBeBeforeDate(date: Date) {
return this.assertion.toBeBeforeDate(date);
return this.assertion.customAssertion(
(v) => v instanceof Date && (v as Date).getTime() < date.getTime(),
`Expected date to be before ${date.toISOString()}`
);
}
toBeAfterDate(date: Date) {
return this.assertion.toBeAfterDate(date);
return this.assertion.customAssertion(
(v) => v instanceof Date && (v as Date).getTime() > date.getTime(),
`Expected date to be after ${date.toISOString()}`
);
}
}