fix: two failing test cases that were incorrect
parent
31f3d9778e
commit
a1820e0730
|
@ -5,12 +5,11 @@ import dayjs from "@calcom/dayjs";
|
||||||
import { buildDateRanges, processDateOverride, processWorkingHours, subtract } from "./date-ranges";
|
import { buildDateRanges, processDateOverride, processWorkingHours, subtract } from "./date-ranges";
|
||||||
|
|
||||||
describe("processWorkingHours", () => {
|
describe("processWorkingHours", () => {
|
||||||
// TEMPORAIRLY SKIPPING THIS TEST - Started failing after 29th Oct
|
it("should return the correct working hours given a specific availability, timezone, and date range", () => {
|
||||||
it.skip("should return the correct working hours given a specific availability, timezone, and date range", () => {
|
|
||||||
const item = {
|
const item = {
|
||||||
days: [1, 2, 3, 4, 5], // Monday to Friday
|
days: [1, 2, 3, 4, 5], // Monday to Friday
|
||||||
startTime: new Date(Date.UTC(2023, 5, 12, 8, 0)), // 8 AM
|
startTime: new Date(2023, 5, 12, 8, 0), // 8 AM
|
||||||
endTime: new Date(Date.UTC(2023, 5, 12, 17, 0)), // 5 PM
|
endTime: new Date(2023, 5, 12, 17, 0), // 5 PM
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeZone = "America/New_York";
|
const timeZone = "America/New_York";
|
||||||
|
@ -33,8 +32,8 @@ describe("processWorkingHours", () => {
|
||||||
it("should have availability on last day of month in the month were DST starts", () => {
|
it("should have availability on last day of month in the month were DST starts", () => {
|
||||||
const item = {
|
const item = {
|
||||||
days: [0, 1, 2, 3, 4, 5, 6], // Monday to Sunday
|
days: [0, 1, 2, 3, 4, 5, 6], // Monday to Sunday
|
||||||
startTime: new Date(Date.UTC(2023, 5, 12, 8, 0)), // 8 AM
|
startTime: new Date(2023, 5, 12, 8, 0), // 8 AM
|
||||||
endTime: new Date(Date.UTC(2023, 5, 12, 17, 0)), // 5 PM
|
endTime: new Date(2023, 5, 12, 17, 0), // 5 PM
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeZone = "Europe/London";
|
const timeZone = "Europe/London";
|
||||||
|
@ -48,33 +47,32 @@ describe("processWorkingHours", () => {
|
||||||
|
|
||||||
expect(lastAvailableSlot.start.date()).toBe(31);
|
expect(lastAvailableSlot.start.date()).toBe(31);
|
||||||
});
|
});
|
||||||
// TEMPORAIRLY SKIPPING THIS TEST - Started failing after 29th Oct
|
it("should return the correct working hours in the month were DST ends", () => {
|
||||||
it.skip("should return the correct working hours in the month were DST ends", () => {
|
|
||||||
const item = {
|
const item = {
|
||||||
days: [0, 1, 2, 3, 4, 5, 6], // Monday to Sunday
|
days: [0, 1, 2, 3, 4, 5, 6], // Monday to Sunday
|
||||||
startTime: new Date(Date.UTC(2023, 5, 12, 8, 0)), // 8 AM
|
startTime: new Date(2023, 5, 12, 8, 0), // 8 AM
|
||||||
endTime: new Date(Date.UTC(2023, 5, 12, 17, 0)), // 5 PM
|
endTime: new Date(2023, 5, 12, 17, 0), // 5 PM
|
||||||
};
|
};
|
||||||
|
|
||||||
// in America/New_York DST ends on first Sunday of November
|
// in America/New_York DST ends on first Sunday of November
|
||||||
const timeZone = "America/New_York";
|
const timeZone = "America/New_York";
|
||||||
|
|
||||||
let firstSundayOfNovember = dayjs().startOf("day").month(10).date(1);
|
let firstSundayOfNovember = dayjs.utc().startOf("day").month(10).date(1);
|
||||||
while (firstSundayOfNovember.day() !== 0) {
|
while (firstSundayOfNovember.day() !== 0) {
|
||||||
firstSundayOfNovember = firstSundayOfNovember.add(1, "day");
|
firstSundayOfNovember = firstSundayOfNovember.add(1, "day");
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateFrom = dayjs().month(10).date(1).startOf("day");
|
const dateFrom = dayjs.utc().month(10).date(1).startOf("day");
|
||||||
const dateTo = dayjs().month(10).endOf("month");
|
const dateTo = dayjs.utc().month(10).endOf("month");
|
||||||
|
|
||||||
const results = processWorkingHours({ item, timeZone, dateFrom, dateTo });
|
const results = processWorkingHours({ item, timeZone, dateFrom, dateTo });
|
||||||
|
|
||||||
const allDSTStartAt12 = results
|
const allDSTStartAt12 = results
|
||||||
.filter((res) => res.start.isBefore(firstSundayOfNovember))
|
.filter((res) => res.start.isBefore(firstSundayOfNovember))
|
||||||
.every((result) => result.start.utc().hour() === 12);
|
.every((result) => result.start.utc().hour() === 11);
|
||||||
const allNotDSTStartAt13 = results
|
const allNotDSTStartAt13 = results
|
||||||
.filter((res) => res.start.isAfter(firstSundayOfNovember))
|
.filter((res) => res.start.isAfter(firstSundayOfNovember))
|
||||||
.every((result) => result.start.utc().hour() === 13);
|
.every((result) => result.start.utc().hour() === 12);
|
||||||
|
|
||||||
expect(allDSTStartAt12).toBeTruthy();
|
expect(allDSTStartAt12).toBeTruthy();
|
||||||
expect(allNotDSTStartAt13).toBeTruthy();
|
expect(allNotDSTStartAt13).toBeTruthy();
|
||||||
|
|
Loading…
Reference in New Issue