package caldata import ( "strings" "testing" "time" "github.com/lukaszkasprzak/lectio/internal/calendar" ) func TestOFReadingsByCycle(t *testing.T) { // A synthetic OF day keyed christ-the-king-A must resolve to Matt 25. day := calendar.LiturgicalDay{ Observed: calendar.Celebration{Slug: "christ-the-king", Layer: "temporal"}, SundayCycle: "A", Weekday: time.Sunday, } sel := calendar.Selection{Form: "new"} rs := Readings(sel, nil, time.Date(2026, 11, 22, 0, 0, 0, 0, time.UTC), day) var gospel string for _, r := range rs { if r.Part == "gospel" { gospel = r.Citation } } // The gospel of Christ the King (cycle A) is Matthew 25:31-46. The citation // may spell Matthew as "Mat" (niedziela/ToEnglishRef) or "Matt" (seed); both // resolve to Matthew via books.ini. if !strings.HasPrefix(gospel, "Mat 25") && !strings.HasPrefix(gospel, "Matt 25") { t.Fatalf("christ-the-king-A gospel = %q, want Matthew 25…", gospel) } } func TestOFReadings2026Sunday(t *testing.T) { // End-to-end: the real engine + embedded table resolve a 2026 (cycle A) // Sunday's first + gospel. sel := calendar.DefaultSelection() // Form defaults to the OF ("new") layers := []calendar.Layer{Universal()} d := time.Date(2026, 6, 7, 0, 0, 0, 0, time.UTC) // Ordinary Sunday 10, cycle A day := calendar.Compute(d, sel, layers) rs := Readings(sel, layers, d, day) var hasFirst, hasGospel bool for _, r := range rs { if r.Part == "first" && r.Citation != "" { hasFirst = true } if r.Part == "gospel" && r.Citation != "" { hasGospel = true } } if !hasFirst || !hasGospel { t.Fatalf("2026-06-07 OF readings missing first/gospel: %+v (slug %s cycle %s)", rs, day.Observed.Slug, day.SundayCycle) } } func TestOFWeekdayEmpty(t *testing.T) { day := calendar.LiturgicalDay{ Observed: calendar.Celebration{Slug: "ordinary-weekday", Layer: "temporal"}, Weekday: time.Wednesday, // no SundayCycle key -> deferred phase -> empty } if rs := Readings(calendar.Selection{Form: "new"}, nil, time.Now().UTC(), day); len(rs) != 0 { t.Fatalf("weekday should be empty, got %v", rs) } }