aboutsummaryrefslogtreecommitdiff
path: root/internal/caldata/of_test.go
blob: 7bc2ce1d3347176054d45b86ebf162f3c2d0d679 (plain) (blame)
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
package caldata

import (
	"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
		}
	}
	if gospel == "" || gospel[:4] != "Matt" {
		t.Fatalf("christ-the-king-A gospel = %q, want Matt…", gospel)
	}
}

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)
	}
}