test: Remove mockdate and replate with vitest system time (#9750)

This commit is contained in:
sean-brydon authored and GitHub committed 2023-06-23 16:10:43 +00:00
1 parent a0ece0d77e
commit 0b704b9ed4
7 files changed
+20 -24

No files matched your search

@@ -1,9 +1,11 @@
import MockDate from "mockdate";
import { expect, it } from "vitest";
import { expect, it, beforeAll, vi } from "vitest";
import { getAggregateWorkingHours } from "@calcom/core/getAggregateWorkingHours";
MockDate.set("2021-06-20T11:59:59Z");
beforeAll(() => {
vi.setSystemTime(new Date("2021-06-20T11:59:59Z"));
})
const HAWAII_AND_NEWYORK_TEAM = [
{
@@ -1,11 +1,13 @@
import type { Availability } from "@prisma/client";
import MockDate from "mockdate";
import { expect, it } from "vitest";
import { expect, it, beforeAll, vi } from "vitest";
import dayjs from "@calcom/dayjs";
import { getAvailabilityFromSchedule } from "@calcom/lib/availability";
MockDate.set("2021-06-20T11:59:59Z");
beforeAll(() => {
vi.setSystemTime(new Date("2021-06-20T11:59:59Z"));
})
//parse "hh:mm-hh:mm" into <Availability> object
const parseWorkingHours = (workingHours: string) => {
+4 -3
View File
@@ -1,10 +1,11 @@
import MockDate from "mockdate";
import { expect, it } from "vitest";
import { expect, it, vi, beforeAll } from "vitest";
import dayjs from "@calcom/dayjs";
import { getWorkingHours } from "@calcom/lib/availability";
MockDate.set("2021-06-20T11:59:59Z");
beforeAll(() => {
vi.setSystemTime(new Date("2021-06-20T11:59:59Z"));
})
it("correctly translates Availability (UTC+0) to UTC workingHours", async () => {
expect(
+5 -3
View File
@@ -1,11 +1,13 @@
import MockDate from "mockdate";
import { describe, expect, it } from "vitest";
import { describe, expect, it, beforeAll, vi } from "vitest";
import dayjs from "@calcom/dayjs";
import { MINUTES_DAY_END, MINUTES_DAY_START } from "@calcom/lib/availability";
import getSlots from "@calcom/lib/slots";
MockDate.set("2021-06-20T11:59:59Z");
beforeAll(() => {
vi.setSystemTime(new Date("2021-06-20T11:59:59Z"));
})
describe("Tests the slot logic", () => {
it("can fit 24 hourly slots for an empty day", async () => {