Files
ghstats/internal/github/profile_test.go
T
tiennm99 40c311d304 refactor: split language card into repos-per-language and most-commit-language
Align card set with github-profile-summary-cards' 5-card layout:

  0-profile-details.svg       (unchanged)
  1-repos-per-language.svg    (new) owned repos grouped by primary language
  2-most-commit-language.svg  (new) last-year commits attributed to each repo's primary language
  3-stats.svg                 (renumbered)
  4-productive-time.svg       (renumbered)

- FetchProductive now fills p.CommitsByLanguage from the same commit history
  it uses for the heatmap, so no extra API calls are introduced.
- TopRepos carries primary language so productive-time can aggregate by lang.
- LangStat.Bytes renamed to Value (repo count or commit count, context-dependent).
- Shared bar+legend renderer extracted to language_bar.go.
- Ignore generated output/ directory.
2026-04-18 18:57:42 +07:00

35 lines
840 B
Go

package github
import "testing"
func TestSortLangStats(t *testing.T) {
values := map[string]int64{
"Go": 5,
"Python": 3,
"TypeScript": 5, // tie with Go → alphabetical wins
"HTML": 1,
}
colors := map[string]string{
"Go": "#00ADD8",
"Python": "#3572A5",
"TypeScript": "#3178c6",
}
got := sortLangStats(values, colors)
wantOrder := []string{"Go", "TypeScript", "Python", "HTML"}
if len(got) != len(wantOrder) {
t.Fatalf("len=%d want %d", len(got), len(wantOrder))
}
for i, name := range wantOrder {
if got[i].Name != name {
t.Errorf("pos %d: %q want %q", i, got[i].Name, name)
}
}
if got[0].Color != "#00ADD8" {
t.Errorf("Go color=%q want #00ADD8", got[0].Color)
}
if got[3].Color != "" {
t.Errorf("HTML color=%q want empty (missing from colors)", got[3].Color)
}
}