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:
parent
7e3457cce3
commit
300ebe9e98
2 changed files with 2 additions and 2 deletions
|
|
@ -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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 }) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue