import { beforeEach, describe, expect, it, vi } from "vitest"; import { goCustomerBrowseHistory, goCustomerVehicleDemandDetail, goCustomerVehicleDemands, goWanfaRouteDetail, } from "@/lib/navigation"; describe("wanfa route detail navigation", () => { const navigateTo = vi.fn(); beforeEach(() => { navigateTo.mockReset(); vi.stubGlobal("uni", { navigateTo }); }); it("encodes the route id in the detail page URL", () => { goWanfaRouteDetail("family water"); expect(navigateTo).toHaveBeenCalledWith({ url: "/pages/detail/index?routeId=family%20water", }); }); it("opens the two customer record entries and encodes detail ids", () => { goCustomerVehicleDemands(); goCustomerBrowseHistory(); goCustomerVehicleDemandDetail("lead 1"); expect(navigateTo).toHaveBeenNthCalledWith(1, { url: "/pages/mine/vehicle-demands/index", }); expect(navigateTo).toHaveBeenNthCalledWith(2, { url: "/pages/mine/browse-history/index", }); expect(navigateTo).toHaveBeenNthCalledWith(3, { url: "/pages/mine/vehicle-demand-detail?id=lead%201", }); }); });