summaryrefslogtreecommitdiff
path: root/internal/calendar/temporal_test.go
blob: da871a25f3af43cd47a550505bb0051bf7632b5c (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package calendar

import (
	"testing"
	"time"
)

func d(s string) time.Time {
	t, _ := time.Parse("2006-01-02", s)
	return t.UTC()
}

func TestTemporalSeasons(t *testing.T) {
	sel := DefaultSelection()
	cases := []struct {
		date   string
		season Season
	}{
		{"2025-12-01", Advent},    // Mon after Advent I (2025 Advent I = Nov 30)
		{"2025-12-25", Christmas}, // Christmas
		{"2025-03-05", Lent},      // Ash Wednesday 2025
		{"2025-04-20", Easter_},   // Easter Sunday 2025
		{"2025-07-15", Ordinary},  // deep Ordinary Time
	}
	for _, c := range cases {
		got := temporal(d(c.date), sel)
		if got.Season != c.season {
			t.Errorf("temporal(%s).Season = %s, want %s", c.date, got.Season, c.season)
		}
	}
}

func TestTemporalPrivilegedSunday(t *testing.T) {
	// 2nd Sunday of Advent 2025 (Dec 7) is privileged and violet.
	td := temporal(d("2025-12-07"), DefaultSelection())
	if !td.Privileged {
		t.Error("Sunday of Advent must be privileged")
	}
	if td.Colour != Violet {
		t.Errorf("Advent colour = %s want violet", td.Colour)
	}
}

func TestMovableSolemnities(t *testing.T) {
	// Corpus Christi 2025 (Thursday, easter+60) = 2025-06-19.
	td := temporal(d("2025-06-19"), DefaultSelection())
	if td.Cel.Slug != "corpus-christi" {
		t.Errorf("2025-06-19 temporal slug = %q want corpus-christi", td.Cel.Slug)
	}
	if td.Rank != RankSolemnity {
		t.Error("Corpus Christi must be a solemnity")
	}
}