Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
@@ -15,10 +15,9 @@ jest.mock("@/features/Calendars/utils/normalizeCalendar");
|
||||
|
||||
const mockedGetOpenPaasUser = getOpenPaasUser as jest.Mock;
|
||||
const mockedGetUserDetails = getUserDetails as jest.Mock;
|
||||
const mockedgetResourceDetails = getResourceDetails as jest.Mock;
|
||||
const mockedGetResourceDetails = getResourceDetails as jest.Mock;
|
||||
const mockedGetCalendars = getCalendars as jest.Mock;
|
||||
const mockedFormatReduxError = formatReduxError as jest.Mock;
|
||||
const mockedToRejectedError = toRejectedError as jest.Mock;
|
||||
const mockedNormalizeCalendar = normalizeCalendar as jest.Mock;
|
||||
|
||||
describe("getCalendarsListAsync", () => {
|
||||
@@ -143,7 +142,12 @@ describe("getCalendarsListAsync", () => {
|
||||
response: { status: 500 },
|
||||
message: "Server Error",
|
||||
});
|
||||
mockedToRejectedError.mockReturnValueOnce({
|
||||
|
||||
// toRejectedError is imported from a mocked module; provide the expected return
|
||||
const { toRejectedError } = jest.requireMock("@/utils/errorUtils") as {
|
||||
toRejectedError: jest.Mock;
|
||||
};
|
||||
toRejectedError.mockReturnValueOnce({
|
||||
status: 500,
|
||||
message: "Server Error",
|
||||
});
|
||||
@@ -175,7 +179,7 @@ describe("getCalendarsListAsync", () => {
|
||||
// getUserDetails fails with 404 for the resource ID
|
||||
mockedGetUserDetails.mockRejectedValueOnce({ response: { status: 404 } });
|
||||
// Then getResourceDetails is called and succeeds
|
||||
mockedgetResourceDetails.mockResolvedValueOnce({ creator: "creator-456" });
|
||||
mockedGetResourceDetails.mockResolvedValueOnce({ creator: "creator-456" });
|
||||
// Then getUserDetails is called for the creator and succeeds
|
||||
mockedGetUserDetails.mockResolvedValueOnce({
|
||||
firstname: "Creator",
|
||||
@@ -187,7 +191,7 @@ describe("getCalendarsListAsync", () => {
|
||||
const result = await thunk(dispatch, getState, undefined);
|
||||
|
||||
const payload = result.payload as any;
|
||||
expect(mockedgetResourceDetails).toHaveBeenCalledWith("resource-123");
|
||||
expect(mockedGetResourceDetails).toHaveBeenCalledWith("resource-123");
|
||||
expect(mockedGetUserDetails).toHaveBeenCalledWith("creator-456");
|
||||
expect(payload.importedCalendars["cal-1"].owner).toEqual({
|
||||
firstname: "Creator",
|
||||
|
||||
Reference in New Issue
Block a user