2
0
Files
cal/calcom/packages/app-store/tests/__mocks__/OAuthManager.ts
2024-08-09 00:39:27 +02:00

36 lines
876 B
TypeScript

import { beforeEach, vi } from "vitest";
import { mockReset, mockDeep } from "vitest-mock-extended";
import type * as OAuthManager from "../../_utils/oauth/OAuthManager";
vi.mock("../../_utils/oauth/OAuthManager", () => oAuthManagerMock);
beforeEach(() => {
mockReset(oAuthManagerMock);
});
const oAuthManagerMock = mockDeep<typeof OAuthManager>({
fallbackMockImplementation: () => {
throw new Error("Unimplemented");
},
});
export default oAuthManagerMock;
const defaultMockOAuthManager = vi.fn().mockImplementation(() => {
return {
getTokenObjectOrFetch: vi.fn().mockImplementation(() => {
return {
token: {
access_token: "FAKE_ACCESS_TOKEN",
},
};
}),
request: vi.fn().mockResolvedValue({
json: {
calendars: [],
},
}),
};
});
export { oAuthManagerMock, defaultMockOAuthManager };