test(tui): dedupe local bind loopback assertions

This commit is contained in:
Peter Steinberger
2026-02-22 00:26:28 +00:00
parent fad2c0c8a1
commit b55979844b

View File

@@ -84,20 +84,21 @@ describe("resolveGatewayConnection", () => {
});
});
it("uses loopback host when local bind is tailnet", () => {
loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "tailnet" } });
it.each([
{
label: "tailnet",
bind: "tailnet",
setup: () => pickPrimaryTailnetIPv4.mockReturnValue("100.64.0.1"),
},
{
label: "lan",
bind: "lan",
setup: () => pickPrimaryLanIPv4.mockReturnValue("192.168.1.42"),
},
])("uses loopback host when local bind is $label", ({ bind, setup }) => {
loadConfig.mockReturnValue({ gateway: { mode: "local", bind } });
resolveGatewayPort.mockReturnValue(18800);
pickPrimaryTailnetIPv4.mockReturnValue("100.64.0.1");
const result = resolveGatewayConnection({});
expect(result.url).toBe("ws://127.0.0.1:18800");
});
it("uses loopback host when local bind is lan", () => {
loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "lan" } });
resolveGatewayPort.mockReturnValue(18800);
pickPrimaryLanIPv4.mockReturnValue("192.168.1.42");
setup();
const result = resolveGatewayConnection({});