diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 14:20:18 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 14:20:18 +0200 |
| commit | b72b81c410c161797eb525a6231b0517b4def993 (patch) | |
| tree | d8b2be9acd30b73be2fb1d3600c7004770da15b3 /internal/web/render_test.go | |
| parent | e4ac5326a42e45281ac8cdcf45757330bae007e9 (diff) | |
| download | lectio-b72b81c410c161797eb525a6231b0517b4def993.tar.gz lectio-b72b81c410c161797eb525a6231b0517b4def993.zip | |
web: HTML render + embedded themes
Diffstat (limited to 'internal/web/render_test.go')
| -rw-r--r-- | internal/web/render_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/internal/web/render_test.go b/internal/web/render_test.go new file mode 100644 index 0000000..c42e1b1 --- /dev/null +++ b/internal/web/render_test.go @@ -0,0 +1,51 @@ +package web + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/lukaszkasprzak/lectio/internal/liturgy" +) + +func TestRenderReadings(t *testing.T) { + secs := []liturgy.Section{{Heading: "Ewangelia (J 20, 1. 11-18)", PartID: "ewangelia"}} + html := string(RenderReadings(secs, []string{"wuj"}, "new")) + if !strings.Contains(html, "Ewangelia") || !strings.Contains(html, "class=") { + t.Errorf("reading pane missing heading/classes: %q", html[:min(200, len(html))]) + } +} + +func TestBuiltinThemes(t *testing.T) { + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) // no user themes + for _, name := range []string{ + "transfiguration", "desert_fathers", "benedictines", "franciscans", + "memento_mori", "camedules", "advent", "nativity", "lent", "easter", + "pentecost", "ordinary", + } { + if b, err := themeCSS(name); err != nil || len(b) == 0 { + t.Errorf("built-in theme %s not embedded: %v", name, err) + } + } +} + +func TestUserTheme(t *testing.T) { + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) + td := filepath.Join(dir, "lectio", "themes") + os.MkdirAll(td, 0o755) + os.WriteFile(filepath.Join(td, "mine.css"), []byte(".heading{color:#f00}"), 0o644) + found := false + for _, n := range Themes() { + if n == "mine" { + found = true + } + } + if !found { + t.Error("user theme 'mine' not listed by Themes()") + } + if b, err := themeCSS("mine"); err != nil || len(b) == 0 { + t.Errorf("user theme not read: %v", err) + } +} |
