diff options
Diffstat (limited to 'mobile/mobile_test.go')
| -rw-r--r-- | mobile/mobile_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/mobile/mobile_test.go b/mobile/mobile_test.go index 57e835a..1a115f3 100644 --- a/mobile/mobile_test.go +++ b/mobile/mobile_test.go @@ -123,3 +123,48 @@ func BenchmarkDaysWeek(b *testing.B) { Days("2026-07-27", 7, "of", "pl") } } + +// This is the assertion that would have caught the app's dead 1962 checkboxes: +// it listed nine part IDs where the engine emits two. +func TestPartLabelsMatchesWhatTheEngineEmits(t *testing.T) { + var ef []map[string]any + if err := json.Unmarshal([]byte(PartLabels("ef", "pl")), &ef); err != nil { + t.Fatalf("invalid JSON: %v", err) + } + if len(ef) != 2 { + t.Fatalf("ef: got %d labels, want 2: %v", len(ef), ef) + } + if ef[0]["part"] != "epistola" || ef[0]["label"] != "Lekcja" { + t.Errorf("ef[0] = %v, want epistola/Lekcja", ef[0]) + } + if ef[1]["part"] != "evangelium" || ef[1]["label"] != "Ewangelia" { + t.Errorf("ef[1] = %v, want evangelium/Ewangelia", ef[1]) + } + + var of []map[string]any + if err := json.Unmarshal([]byte(PartLabels("of", "pl")), &of); err != nil { + t.Fatalf("invalid JSON: %v", err) + } + if len(of) != 5 { + t.Fatalf("of: got %d labels, want 5: %v", len(of), of) + } + // aklamacja was missing from the app's hardcoded list. + var seen []string + for _, e := range of { + seen = append(seen, e["part"].(string)) + } + want := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "aklamacja", "ewangelia"} + for i := range want { + if seen[i] != want[i] { + t.Errorf("of order = %v, want %v", seen, want) + break + } + } +} + +func TestPartLabelsUnknownForm(t *testing.T) { + // An unknown form is treated as the modern one, matching lectByForm. + if got := PartLabels("nonsense", "en"); got == "[]" { + t.Error("unknown form should fall back to the modern lectionary, not empty") + } +} |
