package chart import ( "strings" "testing" "time" "powerwatts/internal/store" ) func TestFormatGermanNumber(t *testing.T) { tests := map[int]string{ 0: "0", 12: "12", 999: "999", 1000: "1.000", 10000: "10.000", 1234567: "1.234.567", -1000: "-1.000", } for input, want := range tests { if got := FormatGermanNumber(input); got != want { t.Fatalf("FormatGermanNumber(%d) = %q, want %q", input, got, want) } } } func TestBuildHistoryChartEmpty(t *testing.T) { chart := BuildHistoryChart(nil, 0) if !strings.Contains(string(chart), "No power history yet") { t.Fatalf("empty chart did not contain fallback text: %s", string(chart)) } } func TestBuildHistoryChartRendersPolyline(t *testing.T) { history := []store.Sample{ {At: time.Date(2026, 4, 20, 0, 0, 0, 0, time.UTC), Value: 100}, {At: time.Date(2026, 4, 20, 6, 0, 0, 0, time.UTC), Value: 200}, {At: time.Date(2026, 4, 20, 12, 0, 0, 0, time.UTC), Value: 150}, } chartHTML := BuildHistoryChart(history, 0) if !strings.Contains(string(chartHTML), "