cal/packages/ui/components/test-setup.ts
GitStart-Cal.com 6f5d9dc41f
test: Create unit tests for react components in packages/ui/components/form/select (#10459)
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-08-25 12:18:53 +00:00

76 lines
1.4 KiB
TypeScript

import matchers from "@testing-library/jest-dom/matchers";
import { cleanup } from "@testing-library/react";
import { afterEach, expect, vi } from "vitest";
vi.mock("next-auth/react", () => ({
useSession() {
return {};
},
}));
vi.mock("@calcom/features/ee/organizations/hooks", () => ({
useOrgBrandingValues() {
return {};
},
}));
vi.mock("@calcom/features/ee/organizations/context/provider", () => ({
useOrgBranding() {
return {};
},
}));
vi.mock("@calcom/trpc/react", () => ({
trpc: {},
}));
vi.mock("next/navigation", async () => ({
...((await vi.importActual("next/navigation")) as object),
useRouter() {
return {
route: "/",
pathname: "",
query: {},
asPath: "",
push: vi.fn(),
};
},
useSearchParams() {
return new URLSearchParams();
},
}));
vi.mock("@calcom/lib/OgImages", async () => {
return {};
});
vi.mock("@calcom/lib/hooks/useLocale", () => ({
useLocale: () => {
return {
t: (str: string) => str,
};
},
}));
expect.extend({
tabToBeDisabled(received) {
const isDisabled = received.classList.contains("pointer-events-none");
return {
pass: isDisabled,
message: () => `Expected tab to be disabled`,
};
},
});
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
expect.extend(matchers);
afterEach(() => {
cleanup();
});