aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/liturgy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/liturgy_test.go')
-rw-r--r--internal/cli/liturgy_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/cli/liturgy_test.go b/internal/cli/liturgy_test.go
index 91e3974..67303f3 100644
--- a/internal/cli/liturgy_test.go
+++ b/internal/cli/liturgy_test.go
@@ -7,6 +7,7 @@ import (
"strings"
"testing"
+ "github.com/lukaszkasprzak/lectio/internal/bible"
"github.com/lukaszkasprzak/lectio/internal/config"
)
@@ -55,6 +56,37 @@ func TestRunLiturgyTraditionalComputesEF(t *testing.T) {
}
}
+func TestVernacularVersionResolver(t *testing.T) {
+ if got := vernacularVersion(config.Config{ReadingVersion: "drb"}); got != "drb" {
+ t.Fatalf("explicit: %q", got)
+ }
+ if got := vernacularVersion(config.Config{UILanguage: "pl"}); got != "vul" {
+ t.Fatalf("pl should fall back to Latin: %q", got)
+ }
+ if got := vernacularVersion(config.Config{UILanguage: "en"}); got != "drb" {
+ t.Fatalf("en should be drb: %q", got)
+ }
+}
+
+func TestVersionDisplayNameFallsBackToCorpusMeta(t *testing.T) {
+ bible.SetUserCorporaDir("../bible/testdata/corpora")
+ t.Cleanup(func() { bible.SetUserCorporaDir("") })
+
+ // "good" is a user fixture with no i18n entry; its sidecar Name must
+ // surface instead of the bare code.
+ if got := versionDisplayName("en", "good"); got != "Good Test Corpus" {
+ t.Fatalf("expected sidecar Name fallback, got %q", got)
+ }
+ // a known i18n code still uses the localized chrome label.
+ if got := versionDisplayName("en", "drb"); got == "drb" {
+ t.Fatalf("expected localized label, got bare code %q", got)
+ }
+ // a totally unknown code with no sidecar falls back to the bare code.
+ if got := versionDisplayName("en", "zzz-nope"); got != "zzz-nope" {
+ t.Fatalf("expected bare-code fallback, got %q", got)
+ }
+}
+
func TestRunLiturgyUserLayer(t *testing.T) {
dir := t.TempDir()
t.Setenv("LECTIO_CONFIG", filepath.Join(dir, "config.ini"))