aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 9b72bc7..9ca311b 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -59,6 +59,46 @@ func TestWebLoadsFromSeed(t *testing.T) {
if cfg.WebPort != 0 {
t.Errorf("WebPort from seed wrong: got %d, want 0", cfg.WebPort)
}
+ if cfg.WebDisplay != "horizontal" {
+ t.Errorf("WebDisplay from seed wrong: got %q, want %q", cfg.WebDisplay, "horizontal")
+ }
+}
+
+func TestWebDisplayDefault(t *testing.T) {
+ def := Default()
+ if def.WebDisplay != "horizontal" {
+ t.Errorf("WebDisplay default wrong: got %q, want %q", def.WebDisplay, "horizontal")
+ }
+}
+
+func TestWebDisplayLoadsSetting(t *testing.T) {
+ dir := t.TempDir()
+ t.Setenv("XDG_CONFIG_HOME", dir)
+ os.MkdirAll(filepath.Join(dir, "lectio"), 0o755)
+ os.WriteFile(filepath.Join(dir, "lectio", "config.toml"),
+ []byte("web_display = \"vertical\"\n"), 0o644)
+ cfg, err := Load()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cfg.WebDisplay != "vertical" {
+ t.Errorf("WebDisplay = %q, want %q", cfg.WebDisplay, "vertical")
+ }
+}
+
+func TestWebDisplayNormalizesUnknown(t *testing.T) {
+ dir := t.TempDir()
+ t.Setenv("XDG_CONFIG_HOME", dir)
+ os.MkdirAll(filepath.Join(dir, "lectio"), 0o755)
+ os.WriteFile(filepath.Join(dir, "lectio", "config.toml"),
+ []byte("web_display = \"bogus\"\n"), 0o644)
+ cfg, err := Load()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cfg.WebDisplay != "horizontal" {
+ t.Errorf("WebDisplay = %q, want %q (normalized from bogus)", cfg.WebDisplay, "horizontal")
+ }
}
func TestPartShown(t *testing.T) {