fix: scope page insights to reporting periods
This commit is contained in:
@@ -94,3 +94,29 @@ func TestCompletePeriods(t *testing.T) {
|
||||
t.Fatalf("completePeriods() returned %d defaults, want 1", defaultCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrecedingPeriodLabelUsesExactJalaliPeriod(t *testing.T) {
|
||||
location, err := time.LoadLocation("Asia/Tehran")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
periodType string
|
||||
start time.Time
|
||||
want string
|
||||
}{
|
||||
{name: "day", periodType: "DAY", start: time.Date(2026, 7, 23, 0, 0, 0, 0, location), want: "روز ۳۱ تیر ۱۴۰۵"},
|
||||
{name: "week", periodType: "WEEK", start: time.Date(2026, 8, 15, 0, 0, 0, 0, location), want: "هفته ۱۷ مرداد تا ۲۳ مرداد ۱۴۰۵"},
|
||||
{name: "month", periodType: "JALALI_MONTH", start: time.Date(2026, 7, 23, 0, 0, 0, 0, location), want: "تیر ۱۴۰۵"},
|
||||
{name: "season", periodType: "PERSIAN_SEASON", start: time.Date(2026, 6, 22, 0, 0, 0, 0, location), want: "بهار ۱۴۰۵"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, ok := PrecedingPeriodLabel(tt.periodType, tt.start)
|
||||
if !ok || got != tt.want {
|
||||
t.Fatalf("PrecedingPeriodLabel() = %q, %v; want %q, true", got, ok, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user