35 lines
989 B
TypeScript
35 lines
989 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { shouldSyncCompanySelectionFromRoute } from "./company-selection";
|
|
|
|
describe("shouldSyncCompanySelectionFromRoute", () => {
|
|
it("does not resync when selection already matches the route", () => {
|
|
expect(
|
|
shouldSyncCompanySelectionFromRoute({
|
|
selectionSource: "route_sync",
|
|
selectedCompanyId: "pap",
|
|
routeCompanyId: "pap",
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("defers route sync while a manual company switch is in flight", () => {
|
|
expect(
|
|
shouldSyncCompanySelectionFromRoute({
|
|
selectionSource: "manual",
|
|
selectedCompanyId: "pap",
|
|
routeCompanyId: "ret",
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("syncs back to the route company for non-manual mismatches", () => {
|
|
expect(
|
|
shouldSyncCompanySelectionFromRoute({
|
|
selectionSource: "route_sync",
|
|
selectedCompanyId: "pap",
|
|
routeCompanyId: "ret",
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
});
|