autobaan/test/unit/reservations/entity.spec.ts
Collin Duncan 3e6f7473b4
Some checks are pending
Push to main / test (push) Waiting to run
Push to main / build-image (push) Blocked by required conditions
ci/woodpecker/push/test Pipeline was successful
Fixing isAvailableForReservation function and adding unit tests
2025-04-22 12:56:28 +02:00

19 lines
701 B
TypeScript

import dayjs from '../../../src/common/dayjs'
import { Reservation } from '../../../src/reservations/entity'
describe('reservations.entity', () => {
describe('isAvailableForReservation', () => {
it.each([
{ dateRangeStart: dayjs().add(7, 'day').set('hour', 23), result: true },
{ dateRangeStart: dayjs().subtract(1, 'day'), result: true },
{ dateRangeStart: dayjs(), result: true },
{ dateRangeStart: dayjs().add(8, 'day'), result: false },
])(
'should handle reservation starting at $dateRangeStart and return $result',
({ dateRangeStart, result }) => {
const r = new Reservation({ dateRangeStart })
expect(r.isAvailableForReservation()).toBe(result)
},
)
})
})