[#421] added eslint check to CI (#534)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2026-02-10 10:41:37 +01:00
committed by GitHub
parent 8a6ec8fc39
commit d6e464afad
116 changed files with 1232 additions and 801 deletions
@@ -322,7 +322,7 @@ describe("WebSocketGate", () => {
it("should reset reconnection attempts counter on successful connection", async () => {
jest.useFakeTimers();
const consoleLog = jest.spyOn(console, "log").mockImplementation();
const consoleLog = jest.spyOn(console, "info").mockImplementation();
let onCloseCallback: Function | undefined;
(createWebSocketConnection as jest.Mock).mockImplementation(
@@ -576,7 +576,7 @@ describe("WebSocketGate", () => {
it("should reset attempt counter when online event fires", async () => {
jest.useFakeTimers();
const consoleLog = jest.spyOn(console, "log").mockImplementation();
const consoleLog = jest.spyOn(console, "info").mockImplementation();
let onCloseCallback: Function | undefined;
(createWebSocketConnection as jest.Mock).mockImplementation(
@@ -49,22 +49,22 @@ describe("createWebSocketConnection", () => {
beforeEach(() => {
({ webSocketInstances, mockWebSocket, cleanup } = setupWebsocket());
(window as any).WEBSOCKET_URL = "wss://calendar.example.com";
window.WEBSOCKET_URL = "wss://calendar.example.com";
(fetchWebSocketTicket as jest.Mock).mockResolvedValue(mockTicket);
});
afterEach(() => {
jest.clearAllMocks();
delete (window as any).WEBSOCKET_URL;
delete (window as any).CALENDAR_BASE_URL;
delete window.WEBSOCKET_URL;
delete window.CALENDAR_BASE_URL;
cleanup();
});
/** ---------- Tests ---------- */
it("throws when WEBSOCKET_URL is not defined", async () => {
delete (window as any).WEBSOCKET_URL;
delete window.WEBSOCKET_URL;
const mockCallbacks = {
onMessage: jest.fn(),
};
@@ -88,8 +88,8 @@ describe("createWebSocketConnection", () => {
});
it("creates WebSocket with correct URL and ticket without the WEBSOCKET_URL", async () => {
delete (window as any).WEBSOCKET_URL;
(window as any).CALENDAR_BASE_URL = "https://calendar.example.com";
delete window.WEBSOCKET_URL;
window.CALENDAR_BASE_URL = "https://calendar.example.com";
await createAndOpenConnection();
expect(mockWebSocket).toHaveBeenCalledWith(
@@ -57,7 +57,7 @@ describe("websocket messages storm", () => {
jest.resetModules();
(getDisplayedCalendarRange as jest.Mock).mockReturnValue(mockRange);
(store.getState as jest.Mock).mockReturnValue(mockState);
(window as any).WS_DEBOUNCE_PERIOD_MS = 500;
window.WS_DEBOUNCE_PERIOD_MS = 500;
mockAccumulators.calendarsToRefresh = new Map<string, any>();
mockAccumulators.calendarsToHide = new Set();
mockAccumulators.currentDebouncePeriod = 0;
@@ -118,7 +118,7 @@ describe("websocket messages storm", () => {
});
it("executes immediately when debounce is disabled", () => {
(window as any).WS_DEBOUNCE_PERIOD_MS = 0;
window.WS_DEBOUNCE_PERIOD_MS = 0;
updateCalendars(
{ "/calendars/cal1/entry1": { syncToken: "abc" } },
@@ -42,16 +42,16 @@ describe("registerToCalendars", () => {
});
it("should log registration", () => {
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
const calendarURIs = ["/calendars/cal1", "/calendars/cal2"];
registerToCalendars(mockSocket, calendarURIs);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect(consoleInfoSpy).toHaveBeenCalledWith(
"Registered to calendars",
calendarURIs
);
consoleLogSpy.mockRestore();
consoleInfoSpy.mockRestore();
});
});
@@ -43,16 +43,16 @@ describe("unregisterToCalendars", () => {
});
it("should log unregistration", () => {
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
const calendarURIs = ["/calendars/cal1", "/calendars/cal2"];
unregisterToCalendars(mockSocket, calendarURIs);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect(consoleInfoSpy).toHaveBeenCalledWith(
"Unregistered to calendars",
calendarURIs
);
consoleLogSpy.mockRestore();
consoleInfoSpy.mockRestore();
});
});