refactor: Moving from jest to vitest (#9035)
* Moving to vitest * Rearranging test * Fixing prettier linting * Reverting launch.json * Adjustments * Merged with main and regenerated lockfile * Fixing tests for API * Yarn updated, docs is gone --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>pull/9095/head^2
parent
ae471ce86a
commit
734382b5b3
|
@ -7,6 +7,7 @@ public
|
||||||
|
|
||||||
*.lock
|
*.lock
|
||||||
*.log
|
*.log
|
||||||
|
*.test.ts
|
||||||
|
|
||||||
.gitignore
|
.gitignore
|
||||||
.npmignore
|
.npmignore
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
public/embed
|
public/embed
|
||||||
|
*.test.ts
|
||||||
|
|
|
@ -156,7 +156,6 @@
|
||||||
"@types/stripe": "^8.0.417",
|
"@types/stripe": "^8.0.417",
|
||||||
"@types/uuid": "8.3.1",
|
"@types/uuid": "8.3.1",
|
||||||
"autoprefixer": "^10.4.12",
|
"autoprefixer": "^10.4.12",
|
||||||
"babel-jest": "^28.1.0",
|
|
||||||
"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",
|
||||||
|
@ -165,7 +164,6 @@
|
||||||
"msw": "^0.42.3",
|
"msw": "^0.42.3",
|
||||||
"postcss": "^8.4.18",
|
"postcss": "^8.4.18",
|
||||||
"tailwindcss": "^3.3.1",
|
"tailwindcss": "^3.3.1",
|
||||||
"ts-jest": "^28.0.8",
|
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4"
|
||||||
},
|
},
|
||||||
|
|
|
@ -103,7 +103,7 @@ export default function User(props: inferSSRProps<typeof getServerSideProps> & E
|
||||||
delete query.user; // So it doesn't display in the Link (and make tests fail)
|
delete query.user; // So it doesn't display in the Link (and make tests fail)
|
||||||
const nameOrUsername = user.name || user.username || "";
|
const nameOrUsername = user.name || user.username || "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const telemetry = useTelemetry();
|
const telemetry = useTelemetry();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (top !== window) {
|
if (top !== window) {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import prismaMock from "../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
import { validateIntervalLimitOrder } from "@calcom/lib";
|
import { validateIntervalLimitOrder } from "@calcom/lib";
|
||||||
import { checkBookingLimits, checkBookingLimit } from "@calcom/lib/server";
|
import { checkBookingLimits, checkBookingLimit } from "@calcom/lib/server";
|
||||||
import type { IntervalLimit } from "@calcom/types/Calendar";
|
import type { IntervalLimit } from "@calcom/types/Calendar";
|
||||||
|
|
||||||
import { prismaMock } from "../../../../tests/config/singleton";
|
|
||||||
|
|
||||||
type Mockdata = {
|
type Mockdata = {
|
||||||
id: number;
|
id: number;
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import prismaMock from "../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
import dayjs from "@calcom/dayjs";
|
import dayjs from "@calcom/dayjs";
|
||||||
import { validateIntervalLimitOrder } from "@calcom/lib";
|
import { validateIntervalLimitOrder } from "@calcom/lib";
|
||||||
import { checkDurationLimit, checkDurationLimits } from "@calcom/lib/server";
|
import { checkDurationLimit, checkDurationLimits } from "@calcom/lib/server";
|
||||||
|
|
||||||
import { prismaMock } from "../../../../tests/config/singleton";
|
|
||||||
|
|
||||||
type MockData = {
|
type MockData = {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { expect, it } from "@jest/globals";
|
|
||||||
import MockDate from "mockdate";
|
import MockDate from "mockdate";
|
||||||
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
import { getAggregateWorkingHours } from "@calcom/core/getAggregateWorkingHours";
|
import { getAggregateWorkingHours } from "@calcom/core/getAggregateWorkingHours";
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ const HAWAII_AND_NEWYORK_TEAM = [
|
||||||
/* TODO: Make this test more "professional" */
|
/* TODO: Make this test more "professional" */
|
||||||
it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "COLLECTIVE")).toMatchInlineSnapshot(`
|
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "COLLECTIVE")).toMatchInlineSnapshot(`
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
3,
|
3,
|
||||||
4,
|
4,
|
||||||
5,
|
5,
|
||||||
|
@ -38,16 +38,16 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
"endTime": 360,
|
"endTime": 360,
|
||||||
"startTime": 780,
|
"startTime": 780,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
6,
|
6,
|
||||||
],
|
],
|
||||||
"endTime": 180,
|
"endTime": 180,
|
||||||
"startTime": 0,
|
"startTime": 0,
|
||||||
"userId": 2,
|
"userId": 2,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
2,
|
2,
|
||||||
3,
|
3,
|
||||||
4,
|
4,
|
||||||
|
@ -55,8 +55,8 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
"endTime": 1260,
|
"endTime": 1260,
|
||||||
"startTime": 780,
|
"startTime": 780,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
5,
|
5,
|
||||||
],
|
],
|
||||||
"endTime": 1260,
|
"endTime": 1260,
|
||||||
|
@ -66,9 +66,9 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
`);
|
`);
|
||||||
|
|
||||||
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "ROUND_ROBIN")).toMatchInlineSnapshot(`
|
expect(getAggregateWorkingHours(HAWAII_AND_NEWYORK_TEAM, "ROUND_ROBIN")).toMatchInlineSnapshot(`
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
3,
|
3,
|
||||||
|
@ -79,8 +79,8 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
"startTime": 780,
|
"startTime": 780,
|
||||||
"userId": 1,
|
"userId": 1,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
3,
|
3,
|
||||||
4,
|
4,
|
||||||
5,
|
5,
|
||||||
|
@ -89,16 +89,16 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
"startTime": 0,
|
"startTime": 0,
|
||||||
"userId": 1,
|
"userId": 1,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
6,
|
6,
|
||||||
],
|
],
|
||||||
"endTime": 180,
|
"endTime": 180,
|
||||||
"startTime": 0,
|
"startTime": 0,
|
||||||
"userId": 2,
|
"userId": 2,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
2,
|
2,
|
||||||
3,
|
3,
|
||||||
4,
|
4,
|
||||||
|
@ -107,8 +107,8 @@ it("Sydney and Shiraz can live in harmony 🙏", async () => {
|
||||||
"startTime": 780,
|
"startTime": 780,
|
||||||
"userId": 3,
|
"userId": 3,
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"days": Array [
|
"days": [
|
||||||
5,
|
5,
|
||||||
],
|
],
|
||||||
"endTime": 1439,
|
"endTime": 1439,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect, it } from "@jest/globals";
|
|
||||||
import type { Availability } from "@prisma/client";
|
import type { Availability } from "@prisma/client";
|
||||||
import MockDate from "mockdate";
|
import MockDate from "mockdate";
|
||||||
|
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";
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
/**
|
|
||||||
* !: Stops the `jose` dependency from bundling the browser version and breaking tests
|
|
||||||
* @jest-environment node
|
|
||||||
*/
|
|
||||||
import type {
|
import type {
|
||||||
EventType as PrismaEventType,
|
EventType as PrismaEventType,
|
||||||
User as PrismaUser,
|
User as PrismaUser,
|
||||||
Booking as PrismaBooking,
|
Booking as PrismaBooking,
|
||||||
App as PrismaApp,
|
App as PrismaApp,
|
||||||
} from "@prisma/client";
|
} from "@prisma/client";
|
||||||
|
|
||||||
|
import CalendarManagerMock from "../../../../tests/libs/__mocks__/CalendarManager";
|
||||||
|
import prismaMock from "../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
import { diff } from "jest-diff";
|
import { diff } from "jest-diff";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import { describe, expect, vi, beforeEach, afterEach, test } from "vitest";
|
||||||
|
|
||||||
import logger from "@calcom/lib/logger";
|
import logger from "@calcom/lib/logger";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
@ -18,14 +19,13 @@ import type { BookingStatus } from "@calcom/prisma/enums";
|
||||||
import type { Slot } from "@calcom/trpc/server/routers/viewer/slots/types";
|
import type { Slot } from "@calcom/trpc/server/routers/viewer/slots/types";
|
||||||
import { getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
|
import { getSchedule } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||||
|
|
||||||
import { prismaMock, CalendarManagerMock } from "../../../../tests/config/singleton";
|
|
||||||
|
|
||||||
// TODO: Mock properly
|
// TODO: Mock properly
|
||||||
prismaMock.eventType.findUnique.mockResolvedValue(null);
|
prismaMock.eventType.findUnique.mockResolvedValue(null);
|
||||||
prismaMock.user.findMany.mockResolvedValue([]);
|
prismaMock.user.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
jest.mock("@calcom/lib/constants", () => ({
|
vi.mock("@calcom/lib/constants", () => ({
|
||||||
IS_PRODUCTION: true,
|
IS_PRODUCTION: true,
|
||||||
|
WEBAPP_URL: "http://localhost:3000"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -233,6 +233,13 @@ describe("getSchedule", () => {
|
||||||
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
||||||
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
||||||
|
|
||||||
|
CalendarManagerMock.getBusyCalendarTimes.mockResolvedValue([
|
||||||
|
{
|
||||||
|
start: `${plus2DateString}T04:45:00.000Z`,
|
||||||
|
end: `${plus2DateString}T23:00:00.000Z`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const scenarioData = {
|
const scenarioData = {
|
||||||
hosts: [],
|
hosts: [],
|
||||||
eventTypes: [
|
eventTypes: [
|
||||||
|
@ -261,12 +268,6 @@ describe("getSchedule", () => {
|
||||||
// An event with one accepted booking
|
// An event with one accepted booking
|
||||||
createBookingScenario(scenarioData);
|
createBookingScenario(scenarioData);
|
||||||
|
|
||||||
addBusyTimesInGoogleCalendar([
|
|
||||||
{
|
|
||||||
start: `${plus2DateString}T04:45:00.000Z`,
|
|
||||||
end: `${plus2DateString}T23:00:00.000Z`,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
|
const scheduleForDayWithAGoogleCalendarBooking = await getSchedule({
|
||||||
eventTypeId: 1,
|
eventTypeId: 1,
|
||||||
eventTypeSlug: "",
|
eventTypeSlug: "",
|
||||||
|
@ -492,7 +493,7 @@ describe("getSchedule", () => {
|
||||||
|
|
||||||
// FIXME: Fix minimumBookingNotice is respected test
|
// FIXME: Fix minimumBookingNotice is respected test
|
||||||
test.skip("minimumBookingNotice is respected", async () => {
|
test.skip("minimumBookingNotice is respected", async () => {
|
||||||
jest.useFakeTimers().setSystemTime(
|
vi.useFakeTimers().setSystemTime(
|
||||||
(() => {
|
(() => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
// Beginning of the day in current timezone of the system
|
// Beginning of the day in current timezone of the system
|
||||||
|
@ -571,13 +572,20 @@ describe("getSchedule", () => {
|
||||||
dateString: todayDateString,
|
dateString: todayDateString,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
jest.useRealTimers();
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("afterBuffer and beforeBuffer tests - Non Cal Busy Time", async () => {
|
test("afterBuffer and beforeBuffer tests - Non Cal Busy Time", async () => {
|
||||||
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
||||||
const { dateString: plus3DateString } = getDate({ dateIncrement: 3 });
|
const { dateString: plus3DateString } = getDate({ dateIncrement: 3 });
|
||||||
|
|
||||||
|
CalendarManagerMock.getBusyCalendarTimes.mockResolvedValue([
|
||||||
|
{
|
||||||
|
start: `${plus3DateString}T04:00:00.000Z`,
|
||||||
|
end: `${plus3DateString}T05:59:59.000Z`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const scenarioData = {
|
const scenarioData = {
|
||||||
eventTypes: [
|
eventTypes: [
|
||||||
{
|
{
|
||||||
|
@ -607,13 +615,6 @@ describe("getSchedule", () => {
|
||||||
|
|
||||||
createBookingScenario(scenarioData);
|
createBookingScenario(scenarioData);
|
||||||
|
|
||||||
addBusyTimesInGoogleCalendar([
|
|
||||||
{
|
|
||||||
start: `${plus3DateString}T04:00:00.000Z`,
|
|
||||||
end: `${plus3DateString}T05:59:59.000Z`,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const scheduleForEventOnADayWithNonCalBooking = await getSchedule({
|
const scheduleForEventOnADayWithNonCalBooking = await getSchedule({
|
||||||
eventTypeId: 1,
|
eventTypeId: 1,
|
||||||
eventTypeSlug: "",
|
eventTypeSlug: "",
|
||||||
|
@ -641,6 +642,13 @@ describe("getSchedule", () => {
|
||||||
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
||||||
const { dateString: plus3DateString } = getDate({ dateIncrement: 3 });
|
const { dateString: plus3DateString } = getDate({ dateIncrement: 3 });
|
||||||
|
|
||||||
|
CalendarManagerMock.getBusyCalendarTimes.mockResolvedValue([
|
||||||
|
{
|
||||||
|
start: `${plus3DateString}T04:00:00.000Z`,
|
||||||
|
end: `${plus3DateString}T05:59:59.000Z`,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const scenarioData = {
|
const scenarioData = {
|
||||||
eventTypes: [
|
eventTypes: [
|
||||||
{
|
{
|
||||||
|
@ -679,13 +687,6 @@ describe("getSchedule", () => {
|
||||||
|
|
||||||
createBookingScenario(scenarioData);
|
createBookingScenario(scenarioData);
|
||||||
|
|
||||||
addBusyTimesInGoogleCalendar([
|
|
||||||
{
|
|
||||||
start: `${plus3DateString}T04:00:00.000Z`,
|
|
||||||
end: `${plus3DateString}T05:59:59.000Z`,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const scheduleForEventOnADayWithCalBooking = await getSchedule({
|
const scheduleForEventOnADayWithCalBooking = await getSchedule({
|
||||||
eventTypeId: 1,
|
eventTypeId: 1,
|
||||||
eventTypeSlug: "",
|
eventTypeSlug: "",
|
||||||
|
@ -712,6 +713,8 @@ describe("getSchedule", () => {
|
||||||
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
||||||
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
|
||||||
|
|
||||||
|
CalendarManagerMock.getBusyCalendarTimes.mockResolvedValue([]);
|
||||||
|
|
||||||
const scenarioData = {
|
const scenarioData = {
|
||||||
eventTypes: [
|
eventTypes: [
|
||||||
{
|
{
|
||||||
|
@ -1380,15 +1383,3 @@ const getDate = (param: { dateIncrement?: number; monthIncrement?: number; yearI
|
||||||
dateString: `${year}-${month}-${date}`,
|
dateString: `${year}-${month}-${date}`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Improve this to validate the arguments passed to getBusyCalendarTimes if they are valid or not.
|
|
||||||
*/
|
|
||||||
function addBusyTimesInGoogleCalendar(
|
|
||||||
busy: {
|
|
||||||
start: string;
|
|
||||||
end: string;
|
|
||||||
}[]
|
|
||||||
) {
|
|
||||||
CalendarManagerMock.getBusyCalendarTimes.mockResolvedValue(busy);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { expect, it } from "@jest/globals";
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
import { filterByCities, addCitiesToDropdown, handleOptionLabel } from "@calcom/lib/timezone";
|
import { filterByCities, addCitiesToDropdown, handleOptionLabel } from "@calcom/lib/timezone";
|
||||||
|
|
||||||
|
@ -34,25 +34,25 @@ const option = {
|
||||||
};
|
};
|
||||||
|
|
||||||
it("should return empty array for an empty string", () => {
|
it("should return empty array for an empty string", () => {
|
||||||
expect(filterByCities("", cityData)).toMatchInlineSnapshot(`Array []`);
|
expect(filterByCities("", cityData)).toMatchInlineSnapshot(`[]`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should filter cities for a valid city name", () => {
|
it("should filter cities for a valid city name", () => {
|
||||||
expect(filterByCities("San Francisco", cityData)).toMatchInlineSnapshot(`
|
expect(filterByCities("San Francisco", cityData)).toMatchInlineSnapshot(`
|
||||||
Array [
|
[
|
||||||
Object {
|
{
|
||||||
"city": "San Francisco",
|
"city": "San Francisco",
|
||||||
"timezone": "America/Argentina/Cordoba",
|
"timezone": "America/Argentina/Cordoba",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"city": "San Francisco de Macoris",
|
"city": "San Francisco de Macoris",
|
||||||
"timezone": "America/Santo_Domingo",
|
"timezone": "America/Santo_Domingo",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"city": "San Francisco Gotera",
|
"city": "San Francisco Gotera",
|
||||||
"timezone": "America/El_Salvador",
|
"timezone": "America/El_Salvador",
|
||||||
},
|
},
|
||||||
Object {
|
{
|
||||||
"city": "San Francisco",
|
"city": "San Francisco",
|
||||||
"timezone": "America/Los_Angeles",
|
"timezone": "America/Los_Angeles",
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ it("should filter cities for a valid city name", () => {
|
||||||
|
|
||||||
it("should return appropriate timezone(s) for a given city name array", () => {
|
it("should return appropriate timezone(s) for a given city name array", () => {
|
||||||
expect(addCitiesToDropdown(cityData)).toMatchInlineSnapshot(`
|
expect(addCitiesToDropdown(cityData)).toMatchInlineSnapshot(`
|
||||||
Object {
|
{
|
||||||
"America/Argentina/Cordoba": "San Francisco",
|
"America/Argentina/Cordoba": "San Francisco",
|
||||||
"America/El_Salvador": "San Francisco Gotera",
|
"America/El_Salvador": "San Francisco Gotera",
|
||||||
"America/Los_Angeles": "San Francisco",
|
"America/Los_Angeles": "San Francisco",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { expect, it } from "@jest/globals";
|
|
||||||
import MockDate from "mockdate";
|
import MockDate from "mockdate";
|
||||||
|
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";
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import type { EventType } from "@prisma/client";
|
import type { EventType } from "@prisma/client";
|
||||||
import type { Prisma } from "@prisma/client";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import updateChildrenEventTypes from "@calcom/features/ee/managed-event-types/lib/handleChildrenEventTypes";
|
import updateChildrenEventTypes from "@calcom/features/ee/managed-event-types/lib/handleChildrenEventTypes";
|
||||||
import { buildEventType } from "@calcom/lib/test/builder";
|
import { buildEventType } from "@calcom/lib/test/builder";
|
||||||
|
import type { Prisma } from "@calcom/prisma/client";
|
||||||
import type { CompleteEventType, CompleteWorkflowsOnEventTypes } from "@calcom/prisma/zod";
|
import type { CompleteEventType, CompleteWorkflowsOnEventTypes } from "@calcom/prisma/zod";
|
||||||
|
|
||||||
import { prismaMock } from "../../../../tests/config/singleton";
|
import prismaMock from "../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
const mockFindFirstEventType = (data?: Partial<CompleteEventType>) => {
|
const mockFindFirstEventType = (data?: Partial<CompleteEventType>) => {
|
||||||
const eventType = buildEventType(data as Partial<EventType>);
|
const eventType = buildEventType(data as Partial<EventType>);
|
||||||
|
@ -13,13 +14,13 @@ const mockFindFirstEventType = (data?: Partial<CompleteEventType>) => {
|
||||||
return eventType;
|
return eventType;
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.mock("@calcom/emails/email-manager", () => {
|
vi.mock("@calcom/emails/email-manager", () => {
|
||||||
return {
|
return {
|
||||||
sendSlugReplacementEmail: () => ({}),
|
sendSlugReplacementEmail: () => ({}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock("@calcom/lib/server/i18n", () => {
|
vi.mock("@calcom/lib/server/i18n", () => {
|
||||||
return {
|
return {
|
||||||
getTranslation: (key: string) => key,
|
getTranslation: (key: string) => key,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
import { parseZone } from "@calcom/lib/parse-zone";
|
import { parseZone } from "@calcom/lib/parse-zone";
|
||||||
|
|
||||||
const EXPECTED_DATE_STRING = "2021-06-20T11:59:59+02:00";
|
const EXPECTED_DATE_STRING = "2021-06-20T11:59:59+02:00";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { expect, it } from "@jest/globals";
|
|
||||||
import MockDate from "mockdate";
|
import MockDate from "mockdate";
|
||||||
|
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";
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { expect, it } from "vitest";
|
||||||
|
|
||||||
|
import prismaMock from "../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
import { getLuckyUser } from "@calcom/lib/server";
|
import { getLuckyUser } from "@calcom/lib/server";
|
||||||
import { buildUser } from "@calcom/lib/test/builder";
|
import { buildUser } from "@calcom/lib/test/builder";
|
||||||
|
|
||||||
import { prismaMock } from "../../../../tests/config/singleton";
|
|
||||||
|
|
||||||
it("can find lucky user with maximize availability", async () => {
|
it("can find lucky user with maximize availability", async () => {
|
||||||
const user1 = buildUser({
|
const user1 = buildUser({
|
||||||
id: 1,
|
id: 1,
|
||||||
|
|
119
jest.config.ts
119
jest.config.ts
|
@ -1,119 +0,0 @@
|
||||||
import type { Config } from "jest";
|
|
||||||
|
|
||||||
// Added +2 to ensure we need to do some conversions in our tests
|
|
||||||
process.env.TZ = "GMT+2";
|
|
||||||
|
|
||||||
const config: Config = {
|
|
||||||
preset: "ts-jest",
|
|
||||||
verbose: true,
|
|
||||||
projects: [
|
|
||||||
{
|
|
||||||
displayName: "@calcom/web",
|
|
||||||
roots: ["<rootDir>/apps/web"],
|
|
||||||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
||||||
modulePathIgnorePatterns: [
|
|
||||||
//
|
|
||||||
"<rootDir>/apps/web/test/__fixtures__",
|
|
||||||
"<rootDir>/apps/web/node_modules",
|
|
||||||
"<rootDir>/apps/web/dist",
|
|
||||||
],
|
|
||||||
clearMocks: true,
|
|
||||||
setupFilesAfterEnv: ["<rootDir>/tests/config/singleton.ts"],
|
|
||||||
setupFiles: ["<rootDir>/apps/web/test/jest-setup.js"],
|
|
||||||
testMatch: ["**/test/lib/**/*.(spec|test).(ts|tsx|js)", "**/__tests__/**/*.(spec|test).(ts|tsx|js)"],
|
|
||||||
testPathIgnorePatterns: ["<rootDir>/apps/web/.next", "<rootDir>/apps/web/playwright/"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.(js|jsx|ts|tsx)$": ["babel-jest", { presets: ["next/babel"] }],
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
|
|
||||||
testEnvironment: "jsdom",
|
|
||||||
resolver: `<rootDir>/apps/web/test/jest-resolver.js`,
|
|
||||||
moduleNameMapper: {
|
|
||||||
"^@components(.*)$": "<rootDir>/apps/web/components$1",
|
|
||||||
"^@lib(.*)$": "<rootDir>/apps/web/lib$1",
|
|
||||||
"^@server(.*)$": "<rootDir>/apps/web/server$1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: "@calcom/lib",
|
|
||||||
roots: ["<rootDir>/packages/lib"],
|
|
||||||
testEnvironment: "node",
|
|
||||||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.tsx?$": "ts-jest",
|
|
||||||
},
|
|
||||||
globals: {
|
|
||||||
"ts-jest": {
|
|
||||||
tsconfig: "<rootDir>/packages/lib/tsconfig.test.json",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: "@calcom/closecom",
|
|
||||||
roots: ["<rootDir>/packages/app-store/closecom"],
|
|
||||||
testMatch: ["**/test/lib/**/*.(spec|test).(ts|tsx|js)"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.ts?$": "ts-jest",
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
|
|
||||||
testEnvironment: "jsdom",
|
|
||||||
setupFiles: ["<rootDir>/packages/app-store/closecom/test/globals.ts"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: "@calcom/routing-forms",
|
|
||||||
roots: ["<rootDir>/packages/app-store/routing-forms"],
|
|
||||||
testMatch: ["**/test/lib/**/*.(spec|test).(ts|tsx|js)"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.ts?$": "ts-jest",
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
|
|
||||||
testEnvironment: "jsdom",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: "@calcom/features",
|
|
||||||
roots: ["<rootDir>/packages/features"],
|
|
||||||
testMatch: ["**/*.(spec|test).(ts|tsx|js)"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.ts?$": "ts-jest",
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
|
|
||||||
testEnvironment: "jsdom",
|
|
||||||
moduleDirectories: ["node_modules", "<rootDir>"],
|
|
||||||
globals: {
|
|
||||||
"ts-jest": {
|
|
||||||
tsconfig: "<rootDir>/packages/features/tsconfig.json",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// FIXME: Prevent this breaking Jest when API module is missing
|
|
||||||
// {
|
|
||||||
// displayName: "@calcom/api",
|
|
||||||
// roots: ["<rootDir>/apps/api"],
|
|
||||||
// testMatch: ["**/test/lib/**/*.(spec|test).(ts|tsx|js)"],
|
|
||||||
// setupFilesAfterEnv: ["<rootDir>/tests/config/singleton.ts"],
|
|
||||||
// transform: {
|
|
||||||
// "^.+\\.ts?$": "ts-jest",
|
|
||||||
// },
|
|
||||||
// globals: {
|
|
||||||
// "ts-jest": {
|
|
||||||
// tsconfig: "<rootDir>/apps/api/tsconfig.json",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// transformIgnorePatterns: ["/node_modules/", "^.+\\.module\\.(css|sass|scss)$"],
|
|
||||||
// testEnvironment: "node",
|
|
||||||
// clearMocks: true,
|
|
||||||
// moduleNameMapper: {
|
|
||||||
// "^@lib/(.*)$": "<rootDir>/apps/api/lib/$1",
|
|
||||||
// "^@api/(.*)$": "<rootDir>/apps/api/pages/api/$1",
|
|
||||||
// },
|
|
||||||
// // setupFilesAfterEnv: ["<rootDir>/apps/api/jest.setup.ts"], // Uncomment when API becomes public
|
|
||||||
// },
|
|
||||||
],
|
|
||||||
watchPlugins: [
|
|
||||||
"jest-watch-typeahead/filename",
|
|
||||||
"jest-watch-typeahead/testname",
|
|
||||||
"jest-watch-select-projects",
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
20
package.json
20
package.json
|
@ -56,7 +56,7 @@
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"prisma": "yarn workspace @calcom/prisma prisma",
|
"prisma": "yarn workspace @calcom/prisma prisma",
|
||||||
"start": "turbo run start --scope=\"@calcom/web\"",
|
"start": "turbo run start --scope=\"@calcom/web\"",
|
||||||
"tdd": "jest --watch",
|
"tdd": "vitest watch",
|
||||||
"e2e": "NEXT_PUBLIC_IS_E2E=1 yarn playwright test --project=@calcom/web",
|
"e2e": "NEXT_PUBLIC_IS_E2E=1 yarn playwright test --project=@calcom/web",
|
||||||
"e2e:app-store": "QUICK=true yarn playwright test --project=@calcom/app-store",
|
"e2e:app-store": "QUICK=true yarn playwright test --project=@calcom/app-store",
|
||||||
"e2e:embed": "QUICK=true yarn playwright test --project=@calcom/embed-core",
|
"e2e:embed": "QUICK=true yarn playwright test --project=@calcom/embed-core",
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
"test-e2e:embed": "yarn db-seed && yarn e2e:embed",
|
"test-e2e:embed": "yarn db-seed && yarn e2e:embed",
|
||||||
"test-e2e:embed-react": "yarn db-seed && yarn e2e:embed-react",
|
"test-e2e:embed-react": "yarn db-seed && yarn e2e:embed-react",
|
||||||
"test-playwright": "yarn playwright test --config=playwright.config.ts",
|
"test-playwright": "yarn playwright test --config=playwright.config.ts",
|
||||||
"test": "jest",
|
"test": "vitest run",
|
||||||
"type-check": "turbo run type-check",
|
"type-check": "turbo run type-check",
|
||||||
"type-check:ci": "turbo run type-check:ci --log-prefix=none",
|
"type-check:ci": "turbo run type-check:ci --log-prefix=none",
|
||||||
"web": "yarn workspace @calcom/web"
|
"web": "yarn workspace @calcom/web"
|
||||||
|
@ -77,19 +77,17 @@
|
||||||
"@playwright/test": "^1.31.2",
|
"@playwright/test": "^1.31.2",
|
||||||
"@snaplet/copycat": "^0.3.0",
|
"@snaplet/copycat": "^0.3.0",
|
||||||
"@types/dompurify": "^2.4.0",
|
"@types/dompurify": "^2.4.0",
|
||||||
"@types/jest": "^28.1.7",
|
"c8": "^7.13.0",
|
||||||
"dotenv-checker": "^1.1.5",
|
"dotenv-checker": "^1.1.5",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.0",
|
||||||
"jest": "^28.1.0",
|
"jest-diff": "^29.5.0",
|
||||||
"jest-environment-jsdom": "^28.1.3",
|
"jsdom": "^22.0.0",
|
||||||
"jest-mock-extended": "^2.0.7",
|
|
||||||
"jest-watch-select-projects": "^2.0.0",
|
|
||||||
"jest-watch-typeahead": "^2.0.0",
|
|
||||||
"lint-staged": "^12.5.0",
|
"lint-staged": "^12.5.0",
|
||||||
"prettier": "^2.8.6",
|
"prettier": "^2.8.6",
|
||||||
"ts-jest": "^28.0.8",
|
|
||||||
"tsc-absolute": "^1.0.0",
|
"tsc-absolute": "^1.0.0",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4",
|
||||||
|
"vitest": "^0.31.1",
|
||||||
|
"vitest-mock-extended": "^1.1.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"city-timezones": "^1.2.1",
|
"city-timezones": "^1.2.1",
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
"main": "./index.ts",
|
"main": "./index.ts",
|
||||||
"description": "Close is the inside sales CRM of choice for startups and SMBs. Make more calls, send more emails and close more deals starting today.",
|
"description": "Close is the inside sales CRM of choice for startups and SMBs. Make more calls, send more emails and close more deals starting today.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "vitest",
|
||||||
"test:coverage": "jest --coverage"
|
"test:coverage": "vitest run --coverage"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@calcom/lib": "*",
|
"@calcom/lib": "*",
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
jest.mock("@calcom/lib/logger", () => ({
|
import { vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("@calcom/lib/logger", () => ({
|
||||||
default: {
|
default: {
|
||||||
getChildLogger: () => ({
|
getChildLogger: () => ({
|
||||||
debug: jest.fn(),
|
debug: vi.fn(),
|
||||||
error: jest.fn(),
|
error: vi.fn(),
|
||||||
log: jest.fn(),
|
log: vi.fn(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("@calcom/lib/crypto", () => ({
|
vi.mock("@calcom/lib/crypto", () => ({
|
||||||
symmetricDecrypt: () => `{
|
symmetricDecrypt: () => `{
|
||||||
"userApiKey": "test"
|
"userApiKey": "test"
|
||||||
}`,
|
}`,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { expect, vi, afterEach, test } from "vitest";
|
||||||
|
|
||||||
import CloseCom from "@calcom/lib/CloseCom";
|
import CloseCom from "@calcom/lib/CloseCom";
|
||||||
import {
|
import {
|
||||||
getCloseComContactIds,
|
getCloseComContactIds,
|
||||||
|
@ -7,7 +9,7 @@ import {
|
||||||
} from "@calcom/lib/CloseComeUtils";
|
} from "@calcom/lib/CloseComeUtils";
|
||||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||||
|
|
||||||
jest.mock("@calcom/lib/CloseCom", () => ({
|
vi.mock("@calcom/lib/CloseCom", () => ({
|
||||||
default: class {
|
default: class {
|
||||||
constructor() {
|
constructor() {
|
||||||
/* Mock */
|
/* Mock */
|
||||||
|
@ -16,7 +18,7 @@ jest.mock("@calcom/lib/CloseCom", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
// getCloseComLeadId
|
// getCloseComLeadId
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { expect, it, describe } from "@jest/globals";
|
import { describe, expect, it, afterEach, vi } from "vitest";
|
||||||
|
|
||||||
import { jsonLogicToPrisma } from "../../jsonLogicToPrisma";
|
import { jsonLogicToPrisma } from "../../jsonLogicToPrisma";
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("jsonLogicToPrisma - Single Query", () => {
|
describe("jsonLogicToPrisma - Single Query", () => {
|
||||||
|
|
|
@ -304,11 +304,11 @@ const getEventTypesFromDB = async (eventTypeId: number) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...eventType,
|
...eventType,
|
||||||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
|
metadata: EventTypeMetaDataSchema.parse(eventType?.metadata || {}),
|
||||||
recurringEvent: parseRecurringEvent(eventType.recurringEvent),
|
recurringEvent: parseRecurringEvent(eventType?.recurringEvent),
|
||||||
customInputs: customInputSchema.array().parse(eventType.customInputs || []),
|
customInputs: customInputSchema.array().parse(eventType?.customInputs || []),
|
||||||
locations: (eventType.locations ?? []) as LocationObject[],
|
locations: (eventType?.locations ?? []) as LocationObject[],
|
||||||
bookingFields: getBookingFieldsWithSystemFields(eventType),
|
bookingFields: getBookingFieldsWithSystemFields(eventType || {}),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ function getBookingData({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
debugger;
|
||||||
const reqBody = bookingDataSchema.parse(req.body);
|
const reqBody = bookingDataSchema.parse(req.body);
|
||||||
if ("customInputs" in reqBody) {
|
if ("customInputs" in reqBody) {
|
||||||
if (reqBody.customInputs) {
|
if (reqBody.customInputs) {
|
||||||
|
@ -584,7 +584,7 @@ async function handler(
|
||||||
...eventType,
|
...eventType,
|
||||||
bookingFields: getBookingFieldsWithSystemFields(eventType),
|
bookingFields: getBookingFieldsWithSystemFields(eventType),
|
||||||
};
|
};
|
||||||
|
debugger;
|
||||||
const {
|
const {
|
||||||
recurringCount,
|
recurringCount,
|
||||||
allRecurringDates,
|
allRecurringDates,
|
||||||
|
@ -673,7 +673,7 @@ async function handler(
|
||||||
...user,
|
...user,
|
||||||
isFixed,
|
isFixed,
|
||||||
}))
|
}))
|
||||||
: eventType.users;
|
: eventType.users || [];
|
||||||
// loadUsers allows type inferring
|
// loadUsers allows type inferring
|
||||||
let users: (Awaited<ReturnType<typeof loadUsers>>[number] & {
|
let users: (Awaited<ReturnType<typeof loadUsers>>[number] & {
|
||||||
isFixed?: boolean;
|
isFixed?: boolean;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { applyStyleToMultipleVariants } from "./cva";
|
import { applyStyleToMultipleVariants } from "./cva";
|
||||||
|
|
||||||
describe("CVA Utils", () => {
|
describe("CVA Utils", () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { defaultAvatarSrc, getPlaceholderAvatar } from "./defaultAvatarImage";
|
import { defaultAvatarSrc, getPlaceholderAvatar } from "./defaultAvatarImage";
|
||||||
|
|
||||||
describe("Default Avatar Image tests", () => {
|
describe("Default Avatar Image tests", () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { createColorMap } from "./getBrandColours";
|
import { createColorMap } from "./getBrandColours";
|
||||||
|
|
||||||
describe("useGetBrandingColours", () => {
|
describe("useGetBrandingColours", () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { randomString } from "./random";
|
import { randomString } from "./random";
|
||||||
|
|
||||||
describe("Random util tests", () => {
|
describe("Random util tests", () => {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLocation,
|
getLocation,
|
||||||
|
@ -8,11 +9,11 @@ import {
|
||||||
} from "../CalEventParser";
|
} from "../CalEventParser";
|
||||||
import { buildCalendarEvent, buildVideoCallData } from "./builder";
|
import { buildCalendarEvent, buildVideoCallData } from "./builder";
|
||||||
|
|
||||||
jest.mock("@calcom/lib/constants", () => ({
|
vi.mock("@calcom/lib/constants", () => ({
|
||||||
WEBAPP_URL: "http://localhost:3000",
|
WEBAPP_URL: "http://localhost:3000",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("short-uuid", () => ({
|
vi.mock("short-uuid", () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
default: () => ({ fromUUID: () => "FAKE_UUID" }),
|
default: () => ({ fromUUID: () => "FAKE_UUID" }),
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { truncate } from "./text";
|
import { truncate } from "./text";
|
||||||
|
|
||||||
describe("Text util tests", () => {
|
describe("Text util tests", () => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { nameOfDay, weekdayNames } from "./weekday";
|
import { nameOfDay, weekdayNames } from "./weekday";
|
||||||
|
|
||||||
describe("Weekday tests", () => {
|
describe("Weekday tests", () => {
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
import type { PrismaClient } from "@prisma/client";
|
|
||||||
import type { DeepMockProxy } from "jest-mock-extended";
|
|
||||||
import { mockDeep, mockReset } from "jest-mock-extended";
|
|
||||||
|
|
||||||
import * as CalendarManager from "@calcom/core/CalendarManager";
|
|
||||||
import prisma from "@calcom/prisma";
|
|
||||||
|
|
||||||
jest.mock("@calcom/core/CalendarManager");
|
|
||||||
|
|
||||||
jest.mock("@calcom/prisma", () => ({
|
|
||||||
__esModule: true,
|
|
||||||
default: mockDeep<PrismaClient>(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
mockReset(prismaMock);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>;
|
|
||||||
export const CalendarManagerMock = CalendarManager as unknown as DeepMockProxy<typeof CalendarManager>;
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { beforeEach, vi } from "vitest";
|
||||||
|
import { mockReset, mockDeep } from "vitest-mock-extended";
|
||||||
|
|
||||||
|
import type * as CalendarManager from "@calcom/core/CalendarManager";
|
||||||
|
|
||||||
|
vi.mock("@calcom/core/CalendarManager", () => CalendarManagerMock);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockReset(CalendarManagerMock);
|
||||||
|
});
|
||||||
|
|
||||||
|
const CalendarManagerMock = mockDeep<typeof CalendarManager>();
|
||||||
|
export default CalendarManagerMock;
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { PrismaClient } from "@prisma/client";
|
||||||
|
import { beforeEach, vi } from "vitest";
|
||||||
|
import { mockDeep, mockReset } from "vitest-mock-extended";
|
||||||
|
|
||||||
|
vi.mock("@calcom/prisma", () => ({
|
||||||
|
default: prisma,
|
||||||
|
availabilityUserSelect: vi.fn(),
|
||||||
|
userSelect: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockReset(prisma);
|
||||||
|
});
|
||||||
|
|
||||||
|
const prisma = mockDeep<PrismaClient>();
|
||||||
|
export default prisma;
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
coverage: {
|
||||||
|
provider: "c8",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { defineWorkspace } from "vitest/config";
|
||||||
|
|
||||||
|
// defineWorkspace provides a nice type hinting DX
|
||||||
|
export default defineWorkspace([
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
include: ["packages/**/*.{test,spec}.{ts,js}", "apps/**/*.{test,spec}.{ts,js}"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: {
|
||||||
|
name: "@calcom/closecom",
|
||||||
|
include: ["packages/app-store/closecom/**/*.{test,spec}.{ts,js}"],
|
||||||
|
environment: "jsdom",
|
||||||
|
setupFiles: ["packages/app-store/closecom/test/globals.ts"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Reference in New Issue