Skip to content

Commit

Permalink
馃挌 Rework broken test on date
Browse files Browse the repository at this point in the history
Fixes #4209
  • Loading branch information
dubzzz committed Sep 6, 2023
1 parent ff49d3c commit db45538
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/fast-check/test/unit/arbitrary/date.spec.ts
Expand Up @@ -101,7 +101,7 @@ describe('date', () => {
}),
));

it('should always generate dates between min and max given the range and the mapper', () =>
it('should always generate dates between min and max (or invalid ones when accepted) given the range and the mapper', () =>
fc.assert(
fc.property(constraintsArb(), fc.maxSafeNat(), (constraints, mod) => {
// Arrange
Expand All @@ -118,9 +118,11 @@ describe('date', () => {
const d = mapper(rangeMin! + (mod % (rangeMax! - rangeMin! + 1))) as Date;

// Assert
expect(d.getTime()).not.toBe(Number.NaN);
if (constraints.min) expect(d.getTime()).toBeGreaterThanOrEqual(constraints.min.getTime());
if (constraints.max) expect(d.getTime()).toBeLessThanOrEqual(constraints.max.getTime());
if (constraints.noInvalidDate !== false || Number.isNaN(d.getTime())) {
expect(d.getTime()).not.toBe(Number.NaN);
if (constraints.min) expect(d.getTime()).toBeGreaterThanOrEqual(constraints.min.getTime());
if (constraints.max) expect(d.getTime()).toBeLessThanOrEqual(constraints.max.getTime());
}
}),
));

Expand Down

0 comments on commit db45538

Please sign in to comment.