From 300ebe9e98af4b36e502cb6668b6dd823c95edef Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Mon, 13 Feb 2023 11:14:29 +0100 Subject: [PATCH] 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) --- src/common/reservation.ts | 2 +- tests/unit/common/reservation.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/reservation.ts b/src/common/reservation.ts index 1347901..b8cfd30 100644 --- a/src/common/reservation.ts +++ b/src/common/reservation.ts @@ -62,7 +62,7 @@ export class Reservation { */ public isAvailableForReservation(): boolean { return ( - Math.ceil(this.dateRange.start.diff(dayjs(), 'days', true)) <= + Math.floor(this.dateRange.start.diff(dayjs(), 'days', true)) <= RESERVATION_AVAILABLE_WITHIN_DAYS ) } diff --git a/tests/unit/common/reservation.test.ts b/tests/unit/common/reservation.test.ts index 116f59e..61fb3e9 100644 --- a/tests/unit/common/reservation.test.ts +++ b/tests/unit/common/reservation.test.ts @@ -32,7 +32,7 @@ describe('Reservation', () => { test.each([ { reservationDate: dayjs().add(7, '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', ({ reservationDate, expected }) => {