fix: check for panics on page registration. Fix header append bug: was appending multiple ctx_id to the header; feat: handle complex signal init values as json; add tests; other small improvemnts

This commit is contained in:
Joao Goncalves
2025-11-17 16:46:33 -01:00
parent 472351d9a5
commit f5a786730a
6 changed files with 167 additions and 33 deletions

View File

@@ -35,6 +35,7 @@ func TestDatastarJS(t *testing.T) {
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "application/javascript", w.Header().Get("Content-Type"))
assert.Contains(t, w.Body.String(), "🖕JS_DS🚀")
}
func TestSignal(t *testing.T) {
@@ -106,3 +107,10 @@ func TestSyncSignals(t *testing.T) {
patch := <-ctx.patchChan
assert.Equal(t, patch.content, fmt.Sprintf(`{"%s":"updated"}`, sig.ID()))
}
func TestPage_PanicsOnNoView(t *testing.T) {
assert.Panics(t, func() {
v := New()
v.Page("/", func(c *Context) {})
})
}