//go:build windows

package main

import (
	"net/netip"
	"testing"

	"tailscale.com/ipn"
	"tailscale.com/types/views"
)

func TestPreferredAddrStringPrefersIPv4(t *testing.T) {
	prefixes := views.SliceOf([]netip.Prefix{
		netip.MustParsePrefix("fd7a:115c:a1e0::1/128"),
		netip.MustParsePrefix("100.64.0.10/32"),
	})

	if got := preferredAddrString(prefixes); got != "100.64.0.10" {
		t.Fatalf("preferredAddrString() = %q, want %q", got, "100.64.0.10")
	}
}

func TestControllerSummaryTextUsesDefault(t *testing.T) {
	if got := controllerSummaryText(""); got != "https://sdp.mm.md" {
		t.Fatalf("controllerSummaryText(\"\") = %q, want %q", got, "https://sdp.mm.md")
	}
}

func TestStateSummaryText(t *testing.T) {
	tests := map[ipn.State]string{
		ipn.Running:          "已连接",
		ipn.Starting:         "连接中",
		ipn.Stopped:          "已登录，未连接",
		ipn.NeedsMachineAuth: "等待设备授权",
		ipn.InUseOtherUser:   "当前设备有其他登录用户",
		ipn.NeedsLogin:       "未登录",
		ipn.NoState:          "未初始化",
	}

	for state, want := range tests {
		if got := stateSummaryText(state); got != want {
			t.Fatalf("stateSummaryText(%v) = %q, want %q", state, got, want)
		}
	}
}
