aboutsummaryrefslogtreecommitdiff
path: root/mobile/mobile_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-03 23:59:50 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-03 23:59:50 +0200
commit1106568c52265ea3076b9d3f1943c052c83a2a89 (patch)
treee969fca7657b7eeb5d612fc6f966c7f03051aa2e /mobile/mobile_test.go
parent27ceffcb90c0716179342109163c559d492a8abc (diff)
downloadlectio-1106568c52265ea3076b9d3f1943c052c83a2a89.tar.gz
lectio-1106568c52265ea3076b9d3f1943c052c83a2a89.zip
mobile: add PartLabels so the app stops hardcoding part IDs
Diffstat (limited to 'mobile/mobile_test.go')
-rw-r--r--mobile/mobile_test.go45
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")
+ }
+}