mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-25 14:02:58 +00:00
Refine P2P and manual setup workflows
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { probeP2PSetupConnection } from "./p2pSetupConnectionProbe";
|
||||
|
||||
describe("P2P setup connection probe", () => {
|
||||
it("accepts an empty room after the signalling connection opens", async () => {
|
||||
const replicator = {
|
||||
knownAdvertisements: [],
|
||||
setOnSetup: vi.fn(),
|
||||
allowReconnection: vi.fn(),
|
||||
open: vi.fn(async () => undefined),
|
||||
};
|
||||
|
||||
await expect(probeP2PSetupConnection(replicator)).resolves.toEqual({ ok: true });
|
||||
expect(replicator.setOnSetup).toHaveBeenCalledOnce();
|
||||
expect(replicator.allowReconnection).toHaveBeenCalledOnce();
|
||||
expect(replicator.open).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("reports a signalling connection failure", async () => {
|
||||
const replicator = {
|
||||
knownAdvertisements: [],
|
||||
setOnSetup: vi.fn(),
|
||||
allowReconnection: vi.fn(),
|
||||
open: vi.fn(async () => {
|
||||
throw new Error("relay unavailable");
|
||||
}),
|
||||
};
|
||||
|
||||
await expect(probeP2PSetupConnection(replicator)).resolves.toEqual({
|
||||
ok: false,
|
||||
reason: "relay unavailable",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user