Files
gogobee/internal/plugin/dnd_expedition_map_test.go
prosolis 3369d7d8fe gofmt: bring internal/ and cmd/ back to gofmt -l clean
Mechanical `gofmt -w ./internal ./cmd`. Mostly struct-field realignment that
had drifted, plus a few trailing-newline fixes. No behaviour change — gofmt is
semantics-preserving, and build/vet/test are green either side.

Split out from the code-review fixes that follow so those stay reviewable
instead of hiding inside a wall of realignment.
2026-07-10 07:18:07 -07:00

81 lines
2.2 KiB
Go

package plugin
import (
"strings"
"testing"
)
func TestRenderRegionChain_SingleRegionZone(t *testing.T) {
e := &Expedition{ZoneID: ZoneSunkenTemple}
if got := renderRegionChain(e); got != "" {
t.Errorf("expected empty chain for single-region zone, got %q", got)
}
}
func TestRenderRegionChain_MultiRegionMarkers(t *testing.T) {
e := &Expedition{
ZoneID: ZoneUnderdark,
CurrentRegion: "underdark_drow_outpost",
RegionState: map[string]any{
regionStateClearedKey: []string{"underdark_surface_tunnels"},
regionStateBaseCampKey: []string{"underdark_drow_outpost"},
},
}
out := renderRegionChain(e)
if out == "" {
t.Fatalf("expected non-empty chain for multi-region zone")
}
lines := strings.Split(out, "\n")
if len(lines) != 2 {
t.Fatalf("expected 2 lines, got %d (%q)", len(lines), out)
}
bot := lines[1]
// 4 regions: cleared / camp(at-current) / pending / pending
// Camp marker overrides the ▶ (here) per renderRegionChain.
if !strings.Contains(bot, "✓") {
t.Errorf("expected ✓ for cleared region: %q", bot)
}
if !strings.Contains(bot, "⛺") {
t.Errorf("expected ⛺ at base-camp region: %q", bot)
}
if !strings.Contains(bot, "·") {
t.Errorf("expected · for pending region: %q", bot)
}
}
func TestRenderRegionChain_CurrentMarker(t *testing.T) {
e := &Expedition{
ZoneID: ZoneUnderdark,
CurrentRegion: "underdark_drow_outpost",
}
out := renderRegionChain(e)
if !strings.Contains(out, "▶") {
t.Errorf("expected ▶ at current region (no camps yet): %q", out)
}
}
func TestRegionGlyph(t *testing.T) {
cases := map[string]string{
"Surface Tunnels": "ST",
"The Deep Throne": "TDT",
"Drow Outpost": "DO",
"Illithid Warren": "IW",
"Kobold Warrens": "KW",
}
for name, want := range cases {
if got := regionGlyph(name); got != want {
t.Errorf("regionGlyph(%q) = %q, want %q", name, got, want)
}
}
}
func TestRenderRegionLegend_HasAllRegions(t *testing.T) {
e := &Expedition{ZoneID: ZoneUnderdark}
got := renderRegionLegend(e)
for _, want := range []string{"Surface Tunnels", "Drow Outpost", "Illithid Warren", "The Deep Throne"} {
if !strings.Contains(got, want) {
t.Errorf("legend missing %q: %s", want, got)
}
}
}