-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathssr_test.go
49 lines (44 loc) · 933 Bytes
/
ssr_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
package inertia
import (
"html/template"
"testing"
)
func TestSsrResponse_HeadHTML(t *testing.T) {
tests := []struct {
response *SsrResponse
expected template.HTML
}{
{
response: &SsrResponse{
Head: []string{
"<title>Test</title>",
"<meta name=\"description\" content=\"Test\">",
},
},
expected: "<title>Test</title>\n<meta name=\"description\" content=\"Test\">",
},
}
for _, tt := range tests {
if ret := tt.response.HeadHTML(); ret != tt.expected {
t.Errorf("expected %v but %v", tt.expected, ret)
}
}
}
func TestSsrResponse_BodyHTML(t *testing.T) {
tests := []struct {
response *SsrResponse
expected template.HTML
}{
{
response: &SsrResponse{
Body: "<div>Test</div>",
},
expected: "<div>Test</div>",
},
}
for _, tt := range tests {
if ret := tt.response.BodyHTML(); ret != tt.expected {
t.Errorf("expected %v but %v", tt.expected, ret)
}
}
}