CSR-886: a few logic changes found during unit test creation

This commit is contained in:
Adam Caouette 2023-08-02 10:48:22 -04:00
parent 5043de3aef
commit 93749b187e

View file

@ -174,9 +174,8 @@ export default {
return this.todayDateNum + (6 - this.todayDayIndex); return this.todayDateNum + (6 - this.todayDayIndex);
}, },
calendarViewDirection() { calendarViewDirection() {
if (this.selectableDatesSetting === "past") return "past";
if (this.selectableDatesSetting === "custom") return "future"; if (this.selectableDatesSetting === "custom") return "future";
return "none"; return "past";
}, },
selectedDate: { selectedDate: {
get() { get() {
@ -428,7 +427,7 @@ export default {
} else if (direction === "past") { } else if (direction === "past") {
// first 0, then -1 // first 0, then -1
for (let i = 0; i >= 0 - monthsBeforeToLoadOffset; i--) { for (let i = 0; i >= 0 - monthsBeforeToLoadOffset; i--) {
months.unshift(this.getMonthData(i, options)); months.unshift(await this.getMonthData(i, options));
} }
} else { } else {
// TODO - IF A CALENDAR WITH BOTH PAST AND FUTURE WAS EVER NEEDED // TODO - IF A CALENDAR WITH BOTH PAST AND FUTURE WAS EVER NEEDED
@ -610,7 +609,7 @@ export default {
// find the first day-hidden to become the next api call start date // find the first day-hidden to become the next api call start date
monthStartDateNum = monthStartDateNum =
monthToShow.dates.find(({ dayClasses }) => dayClasses.includes("day-hidden")) monthToShow.dates.find(({ dayClasses }) => dayClasses.includes("day-hidden"))
.dateNum - 1; // TRY 2 .dateNum - 1;
} else { } else {
if (this.calendarViewDirection === "future") { if (this.calendarViewDirection === "future") {
monthToShow = this.months.find((month) => monthToShow = this.months.find((month) =>
@ -646,11 +645,12 @@ export default {
this.$store.getters.order.serviceLocation.appointmentType, this.$store.getters.order.serviceLocation.appointmentType,
this.$store.getters.order.serviceLocation.provider.providerNumber this.$store.getters.order.serviceLocation.provider.providerNumber
); );
moreSelectableDates.days.forEach((selectableDate) => { moreSelectableDates.days.forEach((selectableDate) => {
const index = this.selectableDatesData.findIndex( const index = this.selectableDatesData.findIndex(
(dateObj) => dateObj.date === selectableDate.date (dateObj) => dateObj.date === selectableDate.date
); );
if (index === -1) this.selectableDatesData.push(selectableDate.date); if (index === -1) this.selectableDatesData.push(selectableDate);
this.months.forEach((month) => { this.months.forEach((month) => {
// TODO: avoid checking all calendar dates; maybe only ones between monthStart and monthEnd as defined above? // TODO: avoid checking all calendar dates; maybe only ones between monthStart and monthEnd as defined above?
month.dates.forEach((date) => { month.dates.forEach((date) => {