diff --git a/framework/go.mod b/framework/go.mod index af149c0..c992f49 100644 --- a/framework/go.mod +++ b/framework/go.mod @@ -10,6 +10,7 @@ require ( require ( github.com/andybalholm/brotli v1.1.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fasthttp/websocket v1.5.10 // indirect github.com/gofiber/contrib/websocket v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect @@ -19,8 +20,10 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/savsgio/gotils v0.0.0-20240704082632-aef3928b8a38 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.55.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect @@ -28,4 +31,5 @@ require ( golang.org/x/crypto v0.27.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.18.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/framework/h/render_test.go b/framework/h/render_test.go new file mode 100644 index 0000000..1439bb2 --- /dev/null +++ b/framework/h/render_test.go @@ -0,0 +1,57 @@ +package h + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestRender(t *testing.T) { + div := Div( + Id("my-div"), + Attribute("data-attr-2", "value"), + Attributes(&AttributeMap{ + "data-attr-3": "value", + "data-attr-4": "value", + }), + BeforeRequest( + SetText("before request"), + ), + AfterRequest( + SetText("after request"), + ), + Children( + Div(Text("hello, world")), + ), + Text("hello, child"), + ) + + div.attributes["data-attr-1"] = "value" + + result := Render(div) + + assert.Equal(t, + `