diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-03 23:51:54 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-03 23:51:54 +0200 |
| commit | e3d551ebb8f6ac2bf1a7027991a4222e83309a39 (patch) | |
| tree | 9b45f9e86febe0d700c72ae5f074dfa062f178c7 /internal/readings/partids_test.go | |
| parent | f94ceaae997bce2168a5ab9e64a0c3afeafe0cf6 (diff) | |
| download | lectio-e3d551ebb8f6ac2bf1a7027991a4222e83309a39.tar.gz lectio-e3d551ebb8f6ac2bf1a7027991a4222e83309a39.zip | |
readings: 1962 part labels become i18n data; export PartIDs
Diffstat (limited to 'internal/readings/partids_test.go')
| -rw-r--r-- | internal/readings/partids_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/readings/partids_test.go b/internal/readings/partids_test.go index 68f5ec0..1ba9373 100644 --- a/internal/readings/partids_test.go +++ b/internal/readings/partids_test.go @@ -4,6 +4,7 @@ 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 @@ -28,3 +29,47 @@ func TestDayInfoCarriesRank(t *testing.T) { } } } + +// 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 +} |
