diff --git a/src/features/flights-map/components/FlightsMapStartPage.test.tsx b/src/features/flights-map/components/FlightsMapStartPage.test.tsx new file mode 100644 index 00000000..7715ce05 --- /dev/null +++ b/src/features/flights-map/components/FlightsMapStartPage.test.tsx @@ -0,0 +1,90 @@ +/** + * @vitest-environment jsdom + */ + +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { render, screen } from "@testing-library/react"; +import { FlightsMapStartPage } from "./FlightsMapStartPage.js"; + +vi.mock("@modern-js/runtime/router", () => ({ + useParams: () => ({ lang: "ru" }), + Link: ({ children, ...props }: { children: React.ReactNode }) => {children}, +})); + +vi.mock("@/i18n/provider.js", () => ({ + useTranslation: () => ({ t: (key: string) => key, i18n: { language: "ru" } }), +})); + +vi.mock("@/ui/layout/PageTabs.js", () => ({ + PageTabs: () =>
, +})); + +vi.mock("./ClientOnly.js", () => ({ + ClientOnly: ({ children }: { children: React.ReactNode }) => <>{children}>, +})); + +vi.mock("./MapCanvas.js", () => ({ + MapCanvas: () => , +})); + +vi.mock("./FlightsMapFilter.js", () => ({ + FlightsMapFilter: () => , +})); + +vi.mock("@/env/index.js", () => ({ + getEnv: () => ({ API_BASE_URL: "https://api.test" }), +})); + +vi.mock("../hooks/useFlightsMapSearch.js", () => ({ + useFlightsMapSearch: () => ({ routes: [], loading: false, error: null }), +})); + +vi.mock("../hooks/useFlightsMapCalendar.js", () => ({ + useFlightsMapCalendar: () => ({ availableDays: [] }), +})); + +const dictState = { + dictionaries: null as unknown, + loading: true, + error: null as Error | null, +}; +vi.mock("@/shared/dictionaries/index.js", () => ({ + useDictionaries: () => dictState, +})); + +describe("FlightsMapStartPage — dictionaries integration", () => { + beforeEach(() => { + dictState.dictionaries = null; + dictState.loading = true; + dictState.error = null; + }); + + it("shows the loader while dictionaries are loading", () => { + dictState.loading = true; + render(