-
Notifications
You must be signed in to change notification settings - Fork 2
/
gomty_test.go
54 lines (43 loc) · 850 Bytes
/
gomty_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package gomty
import (
"bytes"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRender(t *testing.T) {
h := `
<html>
<head>
<title>My website</title>
</head>
<body>
<h1 class="title">My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>`
code := `package components
import (
g "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
)
func IndexComponent(children ...g.Node) {
HTML(
Head(
TitleEl(g.Text("My website"))),
Body(
H1(
Class("title"), g.Text("My First Heading")),
P(g.Text("My first paragraph."))))
}
`
r := strings.NewReader(h)
buf := new(bytes.Buffer)
err := Transform(r, buf, &Options{
Suffix: "Component",
Package: "components",
Name: "Index",
})
assert.NoError(t, err)
assert.Equal(t, buf.String(), code)
}