diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 12:21:15 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 12:21:15 +0200 |
| commit | 0b68ec046c26292e368494e158cc36b342901a80 (patch) | |
| tree | 87f6d9ba73c9ce827c263915e1ad511ba61084e8 /internal/calendar/calendar_test.go | |
| parent | 4c08e94dbcce8dc7757afba3001abe509bd2b6a8 (diff) | |
| download | lectio-0b68ec046c26292e368494e158cc36b342901a80.tar.gz lectio-0b68ec046c26292e368494e158cc36b342901a80.zip | |
feat(calendar): Compute — build celebrations, apply precedence + transfer, cycles
Also: deterministic pick tiebreak by slug.
Diffstat (limited to 'internal/calendar/calendar_test.go')
| -rw-r--r-- | internal/calendar/calendar_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/calendar/calendar_test.go b/internal/calendar/calendar_test.go new file mode 100644 index 0000000..909f1d8 --- /dev/null +++ b/internal/calendar/calendar_test.go @@ -0,0 +1,39 @@ +package calendar + +import ( + "testing" +) + +func universalTest() Layer { + return Layer{ID: "universal", Type: "universal", Cels: map[string]RawCelebration{ + "assumption": {Fields: map[string]string{ + "date": "08-15", "rank": "solemnity", "class": "bvm", "colour": "white", + "name.en": "Assumption of the BVM", "reading.gospel": "Lk 1:39-56", + }, Variants: map[string]map[string]string{}}, + " st-monday-optional ": {Fields: map[string]string{}, Variants: map[string]map[string]string{}}, + }} +} + +func TestComputeSolemnityBeatsFeria(t *testing.T) { + got := Compute(d("2025-08-15"), DefaultSelection(), []Layer{universalTest()}) + if got.Observed.Slug != "assumption" { + t.Fatalf("2025-08-15 observed = %q want assumption", got.Observed.Slug) + } + if got.Colour != White || got.Observed.Rank != RankSolemnity { + t.Errorf("assumption colour/rank wrong: %s / %v", got.Colour, got.Observed.Rank) + } + if len(got.Observed.Masses) == 0 || got.Observed.Masses[0].Readings[0].Part != "gospel" { + t.Errorf("proper reading not surfaced: %+v", got.Observed.Masses) + } +} + +func TestComputeCycles(t *testing.T) { + // Advent 2024 opens liturgical year 2025 → Sunday cycle C, weekday cycle I. + got := Compute(d("2025-01-15"), DefaultSelection(), []Layer{universalTest()}) + if got.SundayCycle != "C" { + t.Errorf("2024-25 Sunday cycle = %s want C", got.SundayCycle) + } + if got.WeekdayCycle != "I" { + t.Errorf("2025 weekday cycle = %s want I", got.WeekdayCycle) + } +} |
