import { describe, expect, it } from "vitest"; import { hasCompletedInitialSync } from "./initial-sync"; describe("initial sync readiness", () => { it("waits while the newly paired source has never completed a sync", () => { expect( hasCompletedInitialSync( [{ deviceId: "source", lastSyncedAt: undefined }], "source", ), ).toBe(false); }); it("does not accept another mesh peer's completed sync", () => { expect( hasCompletedInitialSync( [ { deviceId: "source" }, { deviceId: "other", lastSyncedAt: 1_700_000_000_000 }, ], "source", ), ).toBe(false); }); it("becomes ready after the paired source records a completed sync", () => { expect( hasCompletedInitialSync( [{ deviceId: "source", lastSyncedAt: 1_700_000_000_000 }], "source", ), ).toBe(true); }); });