-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_cards_test.go
More file actions
67 lines (62 loc) · 1.62 KB
/
context_cards_test.go
File metadata and controls
67 lines (62 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import "testing"
func TestBuildContextCardsUsesYoungestFirstAgeRank(t *testing.T) {
league := LeagueData{
IsDynasty: true,
LeagueSize: 3,
TeamAges: []TeamAgeData{
{TeamName: "Old Team", AvgAge: 29.0, IsUserTeam: false},
{TeamName: "User Team", AvgAge: 24.2, IsUserTeam: true},
{TeamName: "Mid Team", AvgAge: 26.5, IsUserTeam: false},
},
PowerRankings: []PowerRanking{
{IsUserTeam: true, ValueRank: 2},
},
}
cards := buildContextCards(league, 10000, 24.2)
found := false
for _, c := range cards {
if c.Title == "Roster Age" {
found = true
if c.Value != "24.2 yrs (#1st)" {
t.Fatalf("expected youngest rank in value, got %q", c.Value)
}
if c.Trend != "Youngest" {
t.Fatalf("expected Youngest trend, got %q", c.Trend)
}
}
}
if !found {
t.Fatal("expected Roster Age card")
}
}
func TestBuildContextCardsCountsAcquiredFirstRoundPicks(t *testing.T) {
league := LeagueData{
IsDynasty: true,
LeagueSize: 12,
DraftPicks: []DraftPick{
{Year: 2026, Round: 1, IsYours: false}, // acquired 1st
{Year: 2027, Round: 1, IsYours: true}, // original 1st
{Year: 2026, Round: 2, IsYours: true},
},
TeamAges: []TeamAgeData{
{TeamName: "User Team", AvgAge: 26.0, IsUserTeam: true},
},
PowerRankings: []PowerRanking{
{IsUserTeam: true, ValueRank: 4},
},
}
cards := buildContextCards(league, 8000, 26.0)
found := false
for _, c := range cards {
if c.Title == "Draft Capital" {
found = true
if c.Value != "2 1sts" {
t.Fatalf("expected acquired+original 1sts counted, got %q", c.Value)
}
}
}
if !found {
t.Fatal("expected Draft Capital card")
}
}