Updating reservation to round day diff down to allow for reservations up to 7.99 days (e.g. performing a reservation at 21.00 at 07.00 the week before)

This commit is contained in:
Collin Duncan 2023-02-13 11:14:29 +01:00
parent 7e3457cce3
commit 300ebe9e98
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -62,7 +62,7 @@ export class Reservation {
*/ */
public isAvailableForReservation(): boolean { public isAvailableForReservation(): boolean {
return ( return (
Math.ceil(this.dateRange.start.diff(dayjs(), 'days', true)) <= Math.floor(this.dateRange.start.diff(dayjs(), 'days', true)) <=
RESERVATION_AVAILABLE_WITHIN_DAYS RESERVATION_AVAILABLE_WITHIN_DAYS
) )
} }

View file

@ -32,7 +32,7 @@ describe('Reservation', () => {
test.each([ test.each([
{ reservationDate: dayjs().add(7, 'days'), expected: true }, { reservationDate: dayjs().add(7, 'days'), expected: true },
{ reservationDate: dayjs().add(1, 'days'), expected: true }, { reservationDate: dayjs().add(1, 'days'), expected: true },
{ reservationDate: dayjs().add(8, 'days'), expected: false }, { reservationDate: dayjs().add(8, 'days').add(5, 'minutes'), expected: false },
])( ])(
'will properly mark reservation availability according to date', 'will properly mark reservation availability according to date',
({ reservationDate, expected }) => { ({ reservationDate, expected }) => {