"All new business logic should have corresponding unit tests."
Description
This PR introduces unit tests for the BookingCalendar and PropertyBooking Livewire components. These tests cover the new business logic introduced in these components, ensuring that all possible scenarios and edge cases are tested.
In BookingCalendarTest.php, tests have been added to verify the initialization of dates and bookings in the mount method, the addition of dates in selectDate, and the booking logic in bookProperty.
In PropertyBookingTest.php, tests have been added to verify the initialization of availableDates in the mount method, date selection and validation in selectDate, booking logic in bookViewing, and the rendering of the booking calendar in loadBookingCalendar.
These tests utilize Laravel's testing utilities and model factories to simulate interactions with the Livewire components and assert that the database is updated correctly and that the components behave as expected under various conditions.
PR Feedback (click)
I created this PR to address this rule:
"All new business logic should have corresponding unit tests."
Description
This PR introduces unit tests for the
BookingCalendar
andPropertyBooking
Livewire components. These tests cover the new business logic introduced in these components, ensuring that all possible scenarios and edge cases are tested.The following files have been added:
tests/Feature/Http/Livewire/BookingCalendarTest.php
tests/Feature/Http/Livewire/PropertyBookingTest.php
Summary of Changes
BookingCalendarTest.php
, tests have been added to verify the initialization ofdates
andbookings
in themount
method, the addition of dates inselectDate
, and the booking logic inbookProperty
.PropertyBookingTest.php
, tests have been added to verify the initialization ofavailableDates
in themount
method, date selection and validation inselectDate
, booking logic inbookViewing
, and the rendering of the booking calendar inloadBookingCalendar
.These tests utilize Laravel's testing utilities and model factories to simulate interactions with the Livewire components and assert that the database is updated correctly and that the components behave as expected under various conditions.