// balanceLanding — unit tests (issue #244) // // Covers the pure `deriveLandingState` helper that replaces the old boolean // empty-state guard. No React rendering (this project has no jsdom configured); // the decoupled-guard logic is exercised directly as a pure helper. import { describe, it, expect } from "vitest"; import { deriveLandingState } from "./balanceLanding"; describe("balanceLanding — deriveLandingState", () => { it("0 accounts → empty (regardless of snapshot flag)", () => { expect(deriveLandingState(0, false)).toBe("empty"); // Anomalous (a snapshot implies an account) but handled conservatively. expect(deriveLandingState(0, true)).toBe("empty"); }); it(">=1 account but no snapshot → accounts-no-snapshot (no longer 'empty')", () => { expect(deriveLandingState(1, false)).toBe("accounts-no-snapshot"); expect(deriveLandingState(5, false)).toBe("accounts-no-snapshot"); }); it(">=1 account with a snapshot → populated", () => { expect(deriveLandingState(1, true)).toBe("populated"); expect(deriveLandingState(12, true)).toBe("populated"); }); it("guards against negative counts → empty", () => { expect(deriveLandingState(-1, true)).toBe("empty"); }); });