test: Remove mockdate and replate with vitest system time (#9750)
parent
a0ece0d77e
commit
0b704b9ed4
|
@ -162,7 +162,6 @@
|
||||||
"copy-webpack-plugin": "^11.0.0",
|
"copy-webpack-plugin": "^11.0.0",
|
||||||
"detect-port": "^1.3.0",
|
"detect-port": "^1.3.0",
|
||||||
"env-cmd": "^10.1.0",
|
"env-cmd": "^10.1.0",
|
||||||
"mockdate": "^3.0.5",
|
|
||||||
"module-alias": "^2.2.2",
|
"module-alias": "^2.2.2",
|
||||||
"msw": "^0.42.3",
|
"msw": "^0.42.3",
|
||||||
"postcss": "^8.4.18",
|
"postcss": "^8.4.18",
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import MockDate from "mockdate";
|
import { expect, it, beforeAll, vi } from "vitest";
|
||||||
import { expect, it } from "vitest";
|
|
||||||
|
|
||||||
import { getAggregateWorkingHours } from "@calcom/core/getAggregateWorkingHours";
|
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 = [
|
const HAWAII_AND_NEWYORK_TEAM = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import type { Availability } from "@prisma/client";
|
import type { Availability } from "@prisma/client";
|
||||||
import MockDate from "mockdate";
|
import { expect, it, beforeAll, vi } from "vitest";
|
||||||
import { expect, it } from "vitest";
|
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
import { getAvailabilityFromSchedule } from "@calcom/lib/availability";
|
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
|
//parse "hh:mm-hh:mm" into <Availability> object
|
||||||
const parseWorkingHours = (workingHours: string) => {
|
const parseWorkingHours = (workingHours: string) => {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import MockDate from "mockdate";
|
import { expect, it, vi, beforeAll } from "vitest";
|
||||||
import { expect, it } from "vitest";
|
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
import { getWorkingHours } from "@calcom/lib/availability";
|
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 () => {
|
it("correctly translates Availability (UTC+0) to UTC workingHours", async () => {
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import MockDate from "mockdate";
|
import { describe, expect, it, beforeAll, vi } from "vitest";
|
||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
import { MINUTES_DAY_END, MINUTES_DAY_START } from "@calcom/lib/availability";
|
import { MINUTES_DAY_END, MINUTES_DAY_START } from "@calcom/lib/availability";
|
||||||
import getSlots from "@calcom/lib/slots";
|
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", () => {
|
describe("Tests the slot logic", () => {
|
||||||
it("can fit 24 hourly slots for an empty day", async () => {
|
it("can fit 24 hourly slots for an empty day", async () => {
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
"zustand": "^4.3.2"
|
"zustand": "^4.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
"@testing-library/react-hooks": "^8.0.1"
|
||||||
"mockdate": "^3.0.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4186,7 +4186,6 @@ __metadata:
|
||||||
dompurify: ^2.4.1
|
dompurify: ^2.4.1
|
||||||
framer-motion: ^10.12.8
|
framer-motion: ^10.12.8
|
||||||
lexical: ^0.9.0
|
lexical: ^0.9.0
|
||||||
mockdate: ^3.0.5
|
|
||||||
react-select: ^5.7.0
|
react-select: ^5.7.0
|
||||||
react-sticky-box: ^2.0.4
|
react-sticky-box: ^2.0.4
|
||||||
zustand: ^4.3.2
|
zustand: ^4.3.2
|
||||||
|
@ -4788,7 +4787,6 @@ __metadata:
|
||||||
memory-cache: ^0.2.0
|
memory-cache: ^0.2.0
|
||||||
micro: ^10.0.1
|
micro: ^10.0.1
|
||||||
mime-types: ^2.1.35
|
mime-types: ^2.1.35
|
||||||
mockdate: ^3.0.5
|
|
||||||
module-alias: ^2.2.2
|
module-alias: ^2.2.2
|
||||||
msw: ^0.42.3
|
msw: ^0.42.3
|
||||||
next: ^13.4.6
|
next: ^13.4.6
|
||||||
|
@ -26477,13 +26475,6 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"mockdate@npm:^3.0.5":
|
|
||||||
version: 3.0.5
|
|
||||||
resolution: "mockdate@npm:3.0.5"
|
|
||||||
checksum: 72b66786d9e072379693f80bf9fb82eb5153c9741030a4294184e3ccaf952d0713fae8966f77780580cf902f8ec7ccc95577b0ad47980d255e2ffb71fc7ca49c
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"module-alias@npm:^2.2.2":
|
"module-alias@npm:^2.2.2":
|
||||||
version: 2.2.2
|
version: 2.2.2
|
||||||
resolution: "module-alias@npm:2.2.2"
|
resolution: "module-alias@npm:2.2.2"
|
||||||
|
|
Loading…
Reference in New Issue