diff options
Diffstat (limited to 'internal/web/server_test.go')
| -rw-r--r-- | internal/web/server_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 638eb2b..925ea18 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -407,6 +407,36 @@ func TestChooseListener(t *testing.T) { }) } +// TestVsetEmptyShowsNothing guards the "uncheck all -> show nothing" behavior: +// a form submit (vset present) with no v param yields an empty pane, while a +// fresh visit (no vset) checks the config default and renders it. +func TestVsetEmptyShowsNothing(t *testing.T) { + srv := NewServer(config.Default()) + + // Form submit, every box unchecked: empty pane, nothing checked. + empty := httptest.NewRecorder() + srv.ServeHTTP(empty, httptest.NewRequest("GET", "/readings?vset=1&lectionary=traditional", nil)) + if b := strings.TrimSpace(empty.Body.String()); b != "" { + t.Errorf("readings with vset and no v should be empty, got %q", b) + } + + // Fresh visit (no vset): config default (bt for modern) box is checked. + fresh := httptest.NewRecorder() + srv.ServeHTTP(fresh, httptest.NewRequest("GET", "/", nil)) + if !strings.Contains(fresh.Body.String(), `value="bt" checked`) { + t.Errorf("fresh visit should check the config default (bt) version box") + } + + // Full page with vset and no v: no VERSION box checked (mono may be). + idx := httptest.NewRecorder() + srv.ServeHTTP(idx, httptest.NewRequest("GET", "/?vset=1", nil)) + for _, v := range bibleVersions { + if strings.Contains(idx.Body.String(), `value="`+v+`" checked`) { + t.Errorf("index with vset and no v: %q box should not be checked", v) + } + } +} + // TestReaderPaneOutsideForm guards the mono fix: #pane must render AFTER the // controls </form> so its reading text inherits body's --font-reading (which // the mono toggle flips) instead of the form's --font-ui. |
