Refactor imports (#470)
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import {
|
||||
putEvent,
|
||||
moveEvent,
|
||||
deleteEvent,
|
||||
importEventFromFile,
|
||||
moveEvent,
|
||||
putEvent,
|
||||
searchEvent,
|
||||
} from "../../../src/features/Events/EventApi";
|
||||
import { CalendarEvent } from "../../../src/features/Events/EventsTypes";
|
||||
import { calendarEventToJCal } from "../../../src/features/Events/eventUtils";
|
||||
import { clientConfig } from "../../../src/features/User/oidcAuth";
|
||||
import { api } from "../../../src/utils/apiUtils";
|
||||
} from "@/features/Events/EventApi";
|
||||
import { CalendarEvent } from "@/features/Events/EventsTypes";
|
||||
import { calendarEventToJCal } from "@/features/Events/eventUtils";
|
||||
import { clientConfig } from "@/features/User/oidcAuth";
|
||||
import { api } from "@/utils/apiUtils";
|
||||
|
||||
clientConfig.url = "https://example.com";
|
||||
|
||||
jest.mock("../../../src/utils/apiUtils");
|
||||
jest.mock("@/utils/apiUtils");
|
||||
|
||||
const day = new Date();
|
||||
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import * as appHooks from "@/app/hooks";
|
||||
import { AppDispatch } from "@/app/store";
|
||||
import { InfoRow } from "@/components/Event/InfoRow";
|
||||
import { LONG_DATE_FORMAT } from "@/components/Event/utils/dateTimeFormatters";
|
||||
import {
|
||||
stringAvatar,
|
||||
stringToColor,
|
||||
} from "@/components/Event/utils/eventUtils";
|
||||
import * as calendarSlice from "@/features/Calendars/CalendarSlice";
|
||||
import * as eventThunks from "@/features/Calendars/services";
|
||||
import EventPreviewModal from "@/features/Events/EventDisplayPreview";
|
||||
import EventUpdateModal from "@/features/Events/EventUpdateModal";
|
||||
import {
|
||||
screen,
|
||||
fireEvent,
|
||||
waitFor,
|
||||
act,
|
||||
cleanup,
|
||||
fireEvent,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import EventUpdateModal from "../../../src/features/Events/EventUpdateModal";
|
||||
import EventPreviewModal from "../../../src/features/Events/EventDisplayPreview";
|
||||
import { InfoRow } from "../../../src/components/Event/InfoRow";
|
||||
import {
|
||||
stringToColor,
|
||||
stringAvatar,
|
||||
} from "../../../src/components/Event/utils/eventUtils";
|
||||
import * as appHooks from "../../../src/app/hooks";
|
||||
import { ThunkDispatch } from "@reduxjs/toolkit";
|
||||
import dayjs from "dayjs";
|
||||
import { LONG_DATE_FORMAT } from "../../../src/components/Event/utils/dateTimeFormatters";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
describe("Event Preview Display", () => {
|
||||
const mockOnClose = jest.fn();
|
||||
@@ -747,7 +748,7 @@ describe("Event Preview Display", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
const dispatch = jest.fn() as ThunkDispatch<any, any, any>;
|
||||
const dispatch = jest.fn() as AppDispatch;
|
||||
jest.spyOn(appHooks, "useAppDispatch").mockReturnValue(dispatch);
|
||||
});
|
||||
|
||||
@@ -1831,7 +1832,7 @@ describe("Event Full Display", () => {
|
||||
(promise as any).unwrap = () => promise;
|
||||
return () => promise as any;
|
||||
});
|
||||
const spyRemove = jest.spyOn(eventThunks, "removeEvent");
|
||||
const spyRemove = jest.spyOn(calendarSlice, "removeEvent");
|
||||
|
||||
const testDate = new Date("2025-01-15T10:00:00.000Z");
|
||||
const testEndDate = new Date("2025-01-15T11:00:00.000Z");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as eventThunks from "@/features/Calendars/services";
|
||||
import EventPopover from "@/features/Events/EventModal";
|
||||
import { api } from "@/utils/apiUtils";
|
||||
import { DateSelectArg } from "@fullcalendar/core";
|
||||
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
||||
import EventPopover from "../../../src/features/Events/EventModal";
|
||||
import { api } from "../../../src/utils/apiUtils";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
jest.mock("../../../src/utils/apiUtils");
|
||||
jest.mock("@/utils/apiUtils");
|
||||
|
||||
describe("EventPopover", () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
import { screen, fireEvent, waitFor, act } from "@testing-library/react";
|
||||
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import EventUpdateModal from "../../../src/features/Events/EventUpdateModal";
|
||||
import { EditModeDialog } from "../../../src/components/Event/EditModeDialog";
|
||||
import * as EventApi from "../../../src/features/Events/EventApi";
|
||||
import { RootState } from "@/app/store";
|
||||
import {
|
||||
createEventHandlers,
|
||||
EventHandlersProps,
|
||||
} from "../../../src/components/Calendar/handlers/eventHandlers";
|
||||
import EventPreviewModal from "../../../src/features/Events/EventDisplayPreview";
|
||||
} from "@/components/Calendar/handlers/eventHandlers";
|
||||
import { EditModeDialog } from "@/components/Event/EditModeDialog";
|
||||
import * as eventThunks from "@/features/Calendars/services";
|
||||
import * as EventApi from "@/features/Events/EventApi";
|
||||
import EventPreviewModal from "@/features/Events/EventDisplayPreview";
|
||||
import EventUpdateModal from "@/features/Events/EventUpdateModal";
|
||||
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
||||
import preview from "jest-preview";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
jest.mock("../../../src/components/Event/utils/eventUtils", () => {
|
||||
const actual = jest.requireActual(
|
||||
"../../../src/components/Event/utils/eventUtils"
|
||||
);
|
||||
jest.mock("@/components/Event/utils/eventUtils", () => {
|
||||
const actual = jest.requireActual("@/components/Event/utils/eventUtils");
|
||||
return {
|
||||
...actual,
|
||||
refreshCalendars: jest.fn(() => Promise.resolve()),
|
||||
refreshSingularCalendar: jest.fn(() => Promise.resolve()),
|
||||
};
|
||||
});
|
||||
import preview from "jest-preview";
|
||||
const mockOnClose = jest.fn();
|
||||
const day = new Date("2025-03-15T10:00:00Z");
|
||||
|
||||
@@ -102,7 +101,7 @@ const basePreloadedState = {
|
||||
pending: false,
|
||||
templist: {},
|
||||
},
|
||||
};
|
||||
} as unknown as RootState;
|
||||
|
||||
describe("EditModeDialog Component", () => {
|
||||
beforeEach(() => {
|
||||
@@ -946,7 +945,7 @@ describe("handleRSVP function", () => {
|
||||
|
||||
const {
|
||||
handleRSVP,
|
||||
} = require("../../../src/components/Event/eventHandlers/eventHandlers");
|
||||
} = require("@/components/Event/eventHandlers/eventHandlers");
|
||||
|
||||
jest.spyOn(eventThunks, "putEventAsync").mockImplementation((payload) => {
|
||||
const promise = Promise.resolve(payload);
|
||||
@@ -992,7 +991,7 @@ describe("handleDelete function", () => {
|
||||
|
||||
const {
|
||||
handleDelete,
|
||||
} = require("../../../src/components/Event/eventHandlers/eventHandlers");
|
||||
} = require("@/components/Event/eventHandlers/eventHandlers");
|
||||
|
||||
jest
|
||||
.spyOn(eventThunks, "deleteEventAsync")
|
||||
@@ -1028,7 +1027,7 @@ describe("handleDelete function", () => {
|
||||
|
||||
const {
|
||||
handleDelete,
|
||||
} = require("../../../src/components/Event/eventHandlers/eventHandlers");
|
||||
} = require("@/components/Event/eventHandlers/eventHandlers");
|
||||
|
||||
jest
|
||||
.spyOn(eventThunks, "deleteEventInstanceAsync")
|
||||
@@ -1059,7 +1058,7 @@ describe("handleDelete function", () => {
|
||||
|
||||
const {
|
||||
handleDelete,
|
||||
} = require("../../../src/components/Event/eventHandlers/eventHandlers");
|
||||
} = require("@/components/Event/eventHandlers/eventHandlers");
|
||||
|
||||
jest
|
||||
.spyOn(eventThunks, "deleteEventAsync")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { screen, fireEvent, waitFor, act } from "@testing-library/react";
|
||||
import * as eventUtils from "@/components/Event/utils/eventUtils";
|
||||
import * as CalendarApi from "@/features/Calendars/CalendarApi";
|
||||
import * as EventApi from "@/features/Events/EventApi";
|
||||
import EventUpdateModal from "@/features/Events/EventUpdateModal";
|
||||
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import EventUpdateModal from "../../../src/features/Events/EventUpdateModal";
|
||||
import * as EventApi from "../../../src/features/Events/EventApi";
|
||||
import * as CalendarApi from "../../../src/features/Calendars/CalendarApi";
|
||||
import * as eventUtils from "../../../src/components/Event/utils/eventUtils";
|
||||
|
||||
jest.mock("../../../src/features/Events/EventApi");
|
||||
jest.mock("../../../src/features/Calendars/CalendarApi");
|
||||
jest.mock("@/features/Events/EventApi");
|
||||
jest.mock("@/features/Calendars/CalendarApi");
|
||||
|
||||
describe("EventUpdateModal Timezone Handling", () => {
|
||||
const mockOnClose = jest.fn();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { screen, fireEvent } from "@testing-library/react";
|
||||
import ImportAlert from "@/features/Events/ImportAlert";
|
||||
import { fireEvent, screen } from "@testing-library/react";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import ImportAlert from "../../../src/features/Events/ImportAlert";
|
||||
import { clearError } from "../../../src/features/Calendars/CalendarSlice";
|
||||
|
||||
// Mock the ErrorSnackbar component since we want to test ImportAlert logic,
|
||||
// but we can also test integration if we don't mock it.
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import * as appHooks from "@/app/hooks";
|
||||
import CalendarLayout from "@/components/Calendar/CalendarLayout";
|
||||
import * as calendarUtils from "@/components/Calendar/utils/calendarUtils";
|
||||
import * as eventUtils from "@/components/Event/utils/eventUtils";
|
||||
import * as CalendarSlice from "@/features/Calendars/CalendarSlice";
|
||||
import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import * as eventThunks from "@/features/Calendars/services";
|
||||
import EventPreviewModal from "@/features/Events/EventDisplayPreview";
|
||||
import EventPopover from "@/features/Events/EventModal";
|
||||
import { CalendarEvent } from "@/features/Events/EventsTypes";
|
||||
import EventUpdateModal from "@/features/Events/EventUpdateModal";
|
||||
import * as userApi from "@/features/User/userAPI";
|
||||
import { DateSelectArg } from "@fullcalendar/core";
|
||||
import { jest } from "@jest/globals";
|
||||
import { ThunkDispatch } from "@reduxjs/toolkit";
|
||||
import "@testing-library/jest-dom";
|
||||
import { screen, waitFor, fireEvent, act } from "@testing-library/react";
|
||||
import * as appHooks from "../../../src/app/hooks";
|
||||
import * as eventUtils from "../../../src/components/Event/utils/eventUtils";
|
||||
import * as userApi from "../../../src/features/User/userAPI";
|
||||
import * as calendarUtils from "../../../src/components/Calendar/utils/calendarUtils";
|
||||
import * as eventThunks from "../../../src/features/Calendars/CalendarSlice";
|
||||
import EventPreviewModal from "../../../src/features/Events/EventDisplayPreview";
|
||||
import EventPopover from "../../../src/features/Events/EventModal";
|
||||
import EventUpdateModal from "../../../src/features/Events/EventUpdateModal";
|
||||
import CalendarLayout from "../../../src/components/Calendar/CalendarLayout";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
||||
import { SpiedFunction } from "jest-mock";
|
||||
import { Calendar } from "../../../src/features/Calendars/CalendarTypes";
|
||||
import { CalendarEvent } from "../../../src/features/Events/EventsTypes";
|
||||
import { DateSelectArg } from "@fullcalendar/core";
|
||||
import { renderWithProviders } from "../../utils/Renderwithproviders";
|
||||
|
||||
describe("Update tempcalendars called with correct params", () => {
|
||||
const today = new Date();
|
||||
@@ -612,7 +613,7 @@ describe("Update tempcalendars called with correct params", () => {
|
||||
});
|
||||
|
||||
it("should call emptyEventsCal with correct params before refreshing", async () => {
|
||||
const emptyEventsCalSpy = jest.spyOn(eventThunks, "emptyEventsCal");
|
||||
const emptyEventsCalSpy = jest.spyOn(CalendarSlice, "emptyEventsCal");
|
||||
|
||||
const preloadedState = createPreloadedState(true);
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import {
|
||||
CalendarEvent,
|
||||
RepetitionObject,
|
||||
} from "../../../src/features/Events/EventsTypes";
|
||||
import { CalendarEvent, RepetitionObject } from "@/features/Events/EventsTypes";
|
||||
import {
|
||||
calendarEventToJCal,
|
||||
parseCalendarEvent,
|
||||
combineMasterDateWithFormTime,
|
||||
detectRecurringEventChanges,
|
||||
normalizeRepetition,
|
||||
normalizeTimezone,
|
||||
detectRecurringEventChanges,
|
||||
} from "../../../src/features/Events/eventUtils";
|
||||
import { TIMEZONES } from "../../../src/utils/timezone-data";
|
||||
parseCalendarEvent,
|
||||
} from "@/features/Events/eventUtils";
|
||||
|
||||
describe("parseCalendarEvent", () => {
|
||||
const baseColor = { light: "#00FF00" };
|
||||
|
||||
Reference in New Issue
Block a user