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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package readings
import (
"testing"
"github.com/lukaszkasprzak/lectio/internal/config"
"github.com/lukaszkasprzak/lectio/internal/i18n"
)
// The day header must carry the rank, not just name and colour: the app's
// calendar rows and the CLI's day line both display it.
func TestDayInfoCarriesRank(t *testing.T) {
cases := []struct {
date, lect, wantRank string
}{
// 2026-08-01 is the memorial of St Alphonsus Liguori in the OF.
{"2026-08-01", "new", "memorial"},
// 2026-12-25 is a solemnity.
{"2026-12-25", "new", "solemnity"},
}
for _, c := range cases {
cfg := config.Config{UILanguage: "en", Lectionary: c.lect, All: true}
_, info, err := Load(cfg, Options{Date: c.date, All: true})
if err != nil {
t.Fatalf("%s: load: %v", c.date, err)
}
if info.Rank != c.wantRank {
t.Errorf("%s: rank = %q, want %q", c.date, info.Rank, c.wantRank)
}
}
}
// PartIDs must list exactly the IDs the engine can emit, in display order.
// The app derives its "show readings" checkboxes from this; when it hardcoded
// them instead, seven of the nine 1962 IDs were wrong and the epistle's
// checkbox did nothing.
func TestPartIDs(t *testing.T) {
wantNew := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "aklamacja", "ewangelia"}
wantOld := []string{"epistola", "evangelium"}
if got := PartIDs("new"); !equalSlice(got, wantNew) {
t.Errorf("PartIDs(new) = %v, want %v", got, wantNew)
}
if got := PartIDs("traditional"); !equalSlice(got, wantOld) {
t.Errorf("PartIDs(traditional) = %v, want %v", got, wantOld)
}
if got := PartIDs("nonsense"); len(got) != 0 {
t.Errorf("PartIDs(nonsense) = %v, want empty", got)
}
}
// Every ID PartIDs lists must have a label in every shipped language,
// otherwise a checkbox would render a raw ID like "epistola".
func TestEveryPartIDHasLabels(t *testing.T) {
for _, lect := range []string{"new", "traditional"} {
for _, id := range PartIDs(lect) {
for _, lang := range []string{"en", "pl"} {
if i18n.Get(lang).PartLabel[id] == "" {
t.Errorf("%s/%s: no label for %q", lect, lang, id)
}
}
}
}
}
func equalSlice(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
|