-
Notifications
You must be signed in to change notification settings - Fork 0
/
wutrender_test.go
50 lines (39 loc) · 1.1 KB
/
wutrender_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
package wutrender
import (
// "fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_NewRenderer(t *testing.T) {
r := New(Options{
Directory: "fixtures",
})
assert.Equal(t, len(r.t.Templates()), 3)
}
func Test_TemplateNames(t *testing.T) {
r := New(Options{
Directory: "fixtures",
})
assert.NotEqual(t, r.t.Lookup("base/hello"), nil)
assert.Nil(t, r.t.Lookup("base/notemplate"))
}
func Test_HTML(t *testing.T) {
r := New(Options{
Directory: "fixtures",
})
html, _ := r.Copy().HTML("base/hello", nil)
htmlBind, _ := r.Copy().HTML("base/hello", []string{"willkommen"})
assert.Equal(t, html.String(), "<div>Hello </div>")
assert.Equal(t, htmlBind.String(), "<div>Hello [willkommen]</div>")
}
func Test_LayoutHTML(t *testing.T) {
r := New(Options{
Directory: "fixtures",
Layout: "base/layout",
})
html, err := r.Copy().HTML("base/hello", nil)
assert.Nil(t, err)
htmlBind, _ := r.Copy().HTML("base/hello", []string{"willkommen"})
assert.Equal(t, html.String(), "head\n<div>Hello </div>\nfoot")
assert.Equal(t, htmlBind.String(), "head\n<div>Hello [willkommen]</div>\nfoot")
}