Test FlightsMapStartPage polyline + intermediateIds wiring
This commit is contained in:
@@ -39,8 +39,20 @@ vi.mock("@/env/index.js", () => ({
|
||||
getEnv: () => ({ API_BASE_URL: "https://api.test" }),
|
||||
}));
|
||||
|
||||
const searchState: {
|
||||
routes: Array<{ route: string[]; isDirect: boolean }>;
|
||||
loading: boolean;
|
||||
error: Error | null;
|
||||
} = {
|
||||
routes: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
vi.mock("../hooks/useFlightsMapSearch.js", () => ({
|
||||
useFlightsMapSearch: () => ({ routes: [], loading: false, error: null }),
|
||||
useFlightsMapSearch: () => ({
|
||||
...searchState,
|
||||
refresh: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../hooks/useFlightsMapCalendar.js", () => ({
|
||||
@@ -161,3 +173,59 @@ describe("FlightsMapStartPage — markers from dictionaries", () => {
|
||||
expect(lastMapCanvasProps!["international"]).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("FlightsMapStartPage — polylines from search results (C.3)", () => {
|
||||
beforeEach(() => {
|
||||
lastMapCanvasProps = null;
|
||||
dictState.dictionaries = {
|
||||
cities: [
|
||||
{ code: "A", name: "A", country_code: "RU", location: { lat: 55, lon: 37 } },
|
||||
{ code: "B", name: "B", country_code: "RU", location: { lat: 60, lon: 40 } },
|
||||
{ code: "X", name: "X", country_code: "RU", location: { lat: 58, lon: 38 } },
|
||||
],
|
||||
};
|
||||
dictState.loading = false;
|
||||
dictState.error = null;
|
||||
searchState.routes = [];
|
||||
searchState.loading = false;
|
||||
searchState.error = null;
|
||||
});
|
||||
|
||||
it("passes an empty polylines array when no routes", () => {
|
||||
render(<FlightsMapStartPage />);
|
||||
const polylines = lastMapCanvasProps!["polylines"] as unknown[];
|
||||
expect(polylines).toEqual([]);
|
||||
});
|
||||
|
||||
it("passes an empty intermediateIds when no routes", () => {
|
||||
render(<FlightsMapStartPage />);
|
||||
const ids = lastMapCanvasProps!["intermediateIds"] as string[];
|
||||
expect(ids).toEqual([]);
|
||||
});
|
||||
|
||||
it("flows intermediateIds from a multi-hop route", () => {
|
||||
searchState.routes = [{ route: ["A", "X", "B"], isDirect: false }];
|
||||
|
||||
render(<FlightsMapStartPage />);
|
||||
|
||||
const ids = lastMapCanvasProps!["intermediateIds"] as string[];
|
||||
expect(ids).toEqual(["X"]);
|
||||
});
|
||||
|
||||
it("flows route-mode polylines with correct style flags when search returned routes", () => {
|
||||
searchState.routes = [
|
||||
{ route: ["A", "B"], isDirect: true },
|
||||
{ route: ["A", "X", "B"], isDirect: false },
|
||||
];
|
||||
|
||||
render(<FlightsMapStartPage />);
|
||||
|
||||
const polylines = lastMapCanvasProps!["polylines"] as Array<{
|
||||
style: string;
|
||||
cityIds: string[];
|
||||
}>;
|
||||
expect(polylines).toHaveLength(2);
|
||||
expect(polylines[0]!.style).toBe("direct");
|
||||
expect(polylines[1]!.style).toBe("connecting");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user