Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
@@ -111,8 +111,20 @@ describe("addCalendarResourceAsync thunk", () => {
|
||||
|
||||
expect(mockedToRejectedError).toHaveBeenCalledWith(errorDetails);
|
||||
|
||||
expect(result.type).toBe("calendars/addCalendarResource/rejected");
|
||||
expect(result.payload).toEqual(mockRejectedErrorResult);
|
||||
expect(result.type).toBe("calendars/addCalendarResource/fulfilled");
|
||||
expect(result.payload).toEqual({
|
||||
calId: "res-456/cal-123",
|
||||
color: { background: "#000000", foreground: "#FFFFFF" },
|
||||
desc: "A meeting room",
|
||||
link: "/calendars/user-123/cal-123.json",
|
||||
name: "Resource Room A",
|
||||
owner: {
|
||||
firstname: "",
|
||||
lastname: "Resource Room A",
|
||||
emails: [],
|
||||
resource: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle error if addSharedCalendar fails", async () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
getOpenPaasUser,
|
||||
updateUserConfigurations,
|
||||
getResourceDetails,
|
||||
getUserDetails,
|
||||
} from "@/features/User/userAPI";
|
||||
import { api } from "@/utils/apiUtils";
|
||||
|
||||
@@ -25,6 +26,26 @@ describe("getOpenPaasUser", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getUserDetails", () => {
|
||||
it("should fetch and return user details", async () => {
|
||||
const mockUser = {
|
||||
firstname: "John",
|
||||
lastname: "Doe",
|
||||
emails: ["john@test.com"],
|
||||
};
|
||||
const userId = "123";
|
||||
|
||||
(api.get as jest.Mock).mockReturnValue({
|
||||
json: jest.fn().mockResolvedValue(mockUser),
|
||||
});
|
||||
|
||||
const result = await getUserDetails(userId);
|
||||
|
||||
expect(api.get).toHaveBeenCalledWith(`api/users/${userId}`);
|
||||
expect(result).toEqual(mockUser);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getResourceDetails", () => {
|
||||
it("should fetch and return resource details", async () => {
|
||||
const mockResource = { _id: "res-123", name: "Meeting Room A" };
|
||||
|
||||
Reference in New Issue
Block a user