Files
calendar/tests/libs/__mocks__/checkRateLimitAndThrowError.ts
T
Hariom BalharaandGitHub 6670bbc1d7 fix: Error in team members migration during org onboarding (#15349)
* fix: Error in team members migration during org onboarding

* Add invitationMemberHandler tests

* Add unit tests

* Improve tests and refactor

* Improve tests and refactor

* Fix type issue

* Fix createNewUsersConnectToOrgIfExists args
2024-06-27 00:53:55 +00:00

30 lines
1.0 KiB
TypeScript

import { beforeEach, vi } from "vitest";
import { mockReset, mockDeep } from "vitest-mock-extended";
import type * as checkRateLimitAndThrowError from "@calcom/lib/checkRateLimitAndThrowError";
vi.mock("@calcom/lib/checkRateLimitAndThrowError", () => checkRateLimitAndThrowErrorMock);
beforeEach(() => {
mockReset(checkRateLimitAndThrowErrorMock);
});
const checkRateLimitAndThrowErrorMock = mockDeep<typeof checkRateLimitAndThrowError>();
export const scenarios = {
fakeRateLimitPassed: () => {
// It doesn't matter what the implementation is, as long as it resolves without error
checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockResolvedValue(undefined);
},
fakeRateLimitFailed: () => {
const error = new Error("FAKE_RATE_LIMIT_ERROR");
// It doesn't matter what the implementation is, as long as it resolves without error
checkRateLimitAndThrowErrorMock.checkRateLimitAndThrowError.mockImplementation(() => {
throw error;
});
return error.message;
},
};
export default checkRateLimitAndThrowErrorMock;