import { describe, expect, it, vi } from "vitest"; import { resolveTailnetHostWithRunner } from "./tailscale-status.js";
describe("shared/tailscale-status", () => {
it("returns null when no runner is provided", async () => {
await expect(resolveTailnetHostWithRunner()).resolves.toBeNull();
});
it("prefers DNS names and trims trailing dots from status json", async () => { const run = vi.fn().mockResolvedValue({
code: 0,
stdout: 'noise\n{"Self":{"DNSName":"mac.tail123.ts.net.","TailscaleIPs":["100.64.0.8"]}}',
});
it("falls back across command candidates and then to the first tailscale ip", async () => { const run = vi.fn().mockRejectedValueOnce(new Error("missing binary")).mockResolvedValueOnce({
code: 0,
stdout: '{"Self":{"TailscaleIPs":["100.64.0.9","fd7a::1"]}}',
});
it("falls back to the first tailscale ip when DNSName is blank", async () => { const run = vi.fn().mockResolvedValue({
code: 0,
stdout: '{"Self":{"DNSName":"","TailscaleIPs":["100.64.0.10","fd7a::2"]}}',
});
it("continues to later command candidates when earlier output has no usable host", async () => { const run = vi
.fn()
.mockResolvedValueOnce({ code: 0, stdout: '{"Self":{}}' })
.mockResolvedValueOnce({
code: 0,
stdout: '{"Self":{"DNSName":"backup.tail.ts.net."}}',
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.