feat: restore logging for status 201 in putEvent as requested in PR #54
- Restore test case to verify logging behavior
This commit is contained in:
committed by
Benoit TELLIER
parent
faa1060949
commit
8160ed459a
@@ -65,6 +65,21 @@ describe("eventApi", () => {
|
|||||||
expect(result).toBe(mockResponse);
|
expect(result).toBe(mockResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("putEvent logs when status is 201", async () => {
|
||||||
|
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
|
||||||
|
const mockResponse = { status: 201, url: "/dav/cals/test.ics" };
|
||||||
|
(api as unknown as jest.Mock).mockReturnValue(mockResponse);
|
||||||
|
|
||||||
|
await putEvent(mockEvent);
|
||||||
|
|
||||||
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
||||||
|
"Event created successfully:",
|
||||||
|
"/dav/cals/test.ics"
|
||||||
|
);
|
||||||
|
|
||||||
|
consoleLogSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
test("moveEvent sends MOVE request with destination header", async () => {
|
test("moveEvent sends MOVE request with destination header", async () => {
|
||||||
const mockResponse = { status: 204 };
|
const mockResponse = { status: 204 };
|
||||||
(api as unknown as jest.Mock).mockReturnValue({
|
(api as unknown as jest.Mock).mockReturnValue({
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ export async function putEvent(event: CalendarEvent, calOwnerEmail?: string) {
|
|||||||
"content-type": "text/calendar; charset=utf-8",
|
"content-type": "text/calendar; charset=utf-8",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response.status === 201) {
|
||||||
|
console.log("Event created successfully:", response.url || event.URL);
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user