Skip to content

Commit

Permalink
Added more tests for overnight continous check
Browse files Browse the repository at this point in the history
  • Loading branch information
SanttuA committed May 30, 2024
1 parent 93c48e0 commit 82753df
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions app/shared/overnight-calendar/tests/overnightUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,24 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
end: '2024-04-29T09:00:00+03:00'
})
];
const reservationsB = [
Reservation.build({
begin: '2024-04-27T13:00:00+03:00',
end: '2024-04-29T13:00:00+03:00'
})
];
const reservations2 = [
Reservation.build({
begin: '2024-04-27T13:00:00+03:00',
end: '2024-04-28T09:00:00+03:00'
})
];
const reservations2B = [
Reservation.build({
begin: '2024-04-27T13:00:00+03:00',
end: '2024-04-28T13:00:00+03:00'
})
];
const openingHours = [
{ date: '2024-04-19', closes: null, opens: null },
{ date: '2024-04-20', closes: '2024-04-20T20:00:00+03:00', opens: '2024-04-20T06:00:00+03:00' },
Expand All @@ -807,6 +819,7 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
];
const overnightStartTime = '13:00:00';
const overnightEndTime = '09:00:00';
const overnightEndTime2 = '13:00:00';

test('returns true when no reservations or closed days in selection', () => {
const startDate = moment('2024-04-23').toDate();
Expand All @@ -823,6 +836,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
startDate, endDate, reservations, openingHours, overnightStartTime, overnightEndTime
}))
.toBe(true);
expect(isSelectionContinous({
startDate,
endDate,
reservations: reservationsB,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(true);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
Expand All @@ -832,6 +854,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(true);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(true);
expect(isSelectionContinous({
startDate: startDate3,
endDate: endDate3,
Expand All @@ -841,6 +872,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(true);
expect(isSelectionContinous({
startDate: startDate3,
endDate: endDate3,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(true);
});
test('returns false when reservations or closed days in selection', () => {
const startDate1 = moment('2024-04-23').toDate();
Expand All @@ -862,6 +902,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate1,
endDate: endDate1,
reservations: reservationsB,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate1,
endDate: endDate1,
Expand All @@ -871,6 +920,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate1,
endDate: endDate1,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
Expand All @@ -880,6 +938,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
reservations: reservationsB,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
Expand All @@ -889,6 +956,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate2,
endDate: endDate2,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate3,
endDate: endDate3,
Expand All @@ -898,6 +974,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate3,
endDate: endDate3,
reservations: reservationsB,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate4,
endDate: endDate4,
Expand All @@ -907,6 +992,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate4,
endDate: endDate4,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate5,
endDate: endDate5,
Expand All @@ -916,6 +1010,15 @@ describe('app/shared/overnight-calendar/overnightUtils', () => {
overnightEndTime
}))
.toBe(false);
expect(isSelectionContinous({
startDate: startDate5,
endDate: endDate5,
reservations: reservations2B,
openingHours,
overnightStartTime,
overnightEndTime: overnightEndTime2
}))
.toBe(false);
});
});

Expand Down

0 comments on commit 82753df

Please sign in to comment.