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
|
package calfeed
import (
"testing"
"time"
"github.com/lukaszkasprzak/lectio/internal/caldata"
"github.com/lukaszkasprzak/lectio/internal/calendar"
)
func TestBuildThreeDayRange(t *testing.T) {
sel := calendar.DefaultSelection()
sel.Form = "old"
layers := []calendar.Layer{caldata.Tridentine()}
from := time.Date(2026, 1, 5, 0, 0, 0, 0, time.UTC)
to := time.Date(2026, 1, 7, 0, 0, 0, 0, time.UTC)
days := Build(from, to, "en", sel, layers, func(date time.Time, day calendar.LiturgicalDay) []calendar.Reading {
return caldata.Readings(sel, layers, date, day)
})
if len(days) != 3 {
t.Fatalf("len(days) = %d, want 3", len(days))
}
wantDates := []string{"2026-01-05", "2026-01-06", "2026-01-07"}
seenWeekday := false
feastFound := false
for i, d := range days {
if d.Date != wantDates[i] {
t.Errorf("day %d: date = %q, want %q", i, d.Date, wantDates[i])
}
if d.Weekday != "" {
seenWeekday = true
}
if d.Date == "2026-01-06" && d.Observed.Name != "" {
feastFound = true
}
}
if !seenWeekday {
t.Errorf("expected weekday strings to be set: %+v", days)
}
if !feastFound {
t.Errorf("expected Epiphany (2026-01-06) to have a non-empty Observed.Name: %+v", days)
}
}
|