summaryrefslogtreecommitdiff
path: root/internal/calendar/refine_test.go
blob: 1f376c488ad24a67ac7d512d89ab820a096d3c68 (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
package calendar

import "testing"

func TestChristmasIsSolemnity(t *testing.T) {
	got := Compute(d("2025-12-25"), DefaultSelection(), []Layer{universalTest()})
	if got.Season != Christmas || got.Observed.Slug != "christmas" || got.Observed.Rank != RankSolemnity {
		t.Errorf("2025-12-25 = %s/%s/%v, want christmas/solemnity", got.Season, got.Observed.Slug, got.Observed.Rank)
	}
}

func TestFeastOfLordReplacesSunday(t *testing.T) {
	// A feast of the Lord (band 5) must replace an Ordinary Sunday (band 6);
	// a saint's feast (band 7) must not. 2025-08-10 is an Ordinary Sunday.
	layer := Layer{ID: "universal", Cels: map[string]RawCelebration{
		"transfiguration-test": {Fields: map[string]string{"date": "08-10", "rank": "feast", "class": "lord", "name.en": "L"}, Variants: map[string]map[string]string{}},
	}}
	got := Compute(d("2025-08-10"), DefaultSelection(), []Layer{layer})
	if got.Observed.Slug != "transfiguration-test" {
		t.Errorf("feast of the Lord did not replace the Sunday: observed %q", got.Observed.Slug)
	}

	saintLayer := Layer{ID: "universal", Cels: map[string]RawCelebration{
		"a-saint": {Fields: map[string]string{"date": "08-10", "rank": "feast", "class": "saint", "name.en": "S"}, Variants: map[string]map[string]string{}},
	}}
	got2 := Compute(d("2025-08-10"), DefaultSelection(), []Layer{saintLayer})
	if got2.Observed.Layer != "temporal" {
		t.Errorf("a saint's feast must not replace the Sunday: observed %q", got2.Observed.Slug)
	}
}