initial-sync.test.ts

911 B · raw

1import { describe, expect, it } from "vitest";2import { hasCompletedInitialSync } from "./initial-sync";34describe("initial sync readiness", () => {5  it("waits while the newly paired source has never completed a sync", () => {6    expect(7      hasCompletedInitialSync(8        [{ deviceId: "source", lastSyncedAt: undefined }],9        "source",10      ),11    ).toBe(false);12  });1314  it("does not accept another mesh peer's completed sync", () => {15    expect(16      hasCompletedInitialSync(17        [18          { deviceId: "source" },19          { deviceId: "other", lastSyncedAt: 1_700_000_000_000 },20        ],21        "source",22      ),23    ).toBe(false);24  });2526  it("becomes ready after the paired source records a completed sync", () => {27    expect(28      hasCompletedInitialSync(29        [{ deviceId: "source", lastSyncedAt: 1_700_000_000_000 }],30        "source",31      ),32    ).toBe(true);33  });34});