mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-05-30 08:22:04 +00:00
4aee0862ab
- I4 — TestRenderAll now seeds Name/Company with XML-significant chars that actually hit the render pipeline via cardTitle(). Previous test checked Bio which is no longer rendered, so the assertion was vacuous. - New TestDonutSingleSlice guards against the I1 empty-arc regression: asserts the single-slice path emits <circle> primitives and not the degenerate A-command path. - New TestDonutEmpty covers the zero-stats fallback. - New TestUTCOffsetLabel pins the UTC±N.NN format across UTC, Asia/Saigon, Asia/Kolkata (half-hour), Asia/Kathmandu (quarter-hour). Catches %+.2f regressions.
32 lines
810 B
Go
32 lines
810 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestUTCOffsetLabel checks that half-hour and quarter-hour zones render
|
|
// with a decimal, matching github-profile-summary-cards' "UTC+X.NN" style.
|
|
func TestUTCOffsetLabel(t *testing.T) {
|
|
cases := []struct {
|
|
zone string
|
|
want string // must appear in the label; exact value varies by DST
|
|
}{
|
|
{"UTC", "UTC+0.00"},
|
|
{"Asia/Saigon", "UTC+7.00"},
|
|
{"Asia/Kolkata", "UTC+5.50"}, // half-hour zone
|
|
{"Asia/Kathmandu", "UTC+5.75"}, // quarter-hour zone
|
|
}
|
|
for _, tc := range cases {
|
|
loc, err := time.LoadLocation(tc.zone)
|
|
if err != nil {
|
|
t.Skipf("%s unavailable: %v", tc.zone, err)
|
|
}
|
|
got := utcOffsetLabel(loc)
|
|
if !strings.Contains(got, tc.want) {
|
|
t.Errorf("utcOffsetLabel(%q) = %q, want prefix %q", tc.zone, got, tc.want)
|
|
}
|
|
}
|
|
}
|