forked from maxence-charriere/go-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_test.go
More file actions
94 lines (76 loc) · 1.37 KB
/
app_test.go
File metadata and controls
94 lines (76 loc) · 1.37 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package app
import (
"testing"
"github.com/murlokswarm/log"
)
type Hello struct {
Greeting string
BadMarkup bool
BadMarkupSync bool
}
func (h *Hello) OnInputChange(a ChangeArg) {
h.Greeting = a.Value
Render(h)
}
func (h *Hello) Render() string {
return `
<div>
Hello,
<span>
{{if .Greeting}}
{{html .Greeting}}
{{else}}
World
{{end}}
</span>
<input onchange="OnInputChange" />
{{if .BadMarkup}}<div></span>{{end}}
{{if .BadMarkupSync}}
<div></span>
{{else}}
<div>Foo</div>
{{end}}
</div>
`
}
func init() {
RegisterComponent(&Hello{})
}
func TestRun(t *testing.T) {
OnFinalize = func() {
log.Info("OnFinalize called")
}
Run()
}
func TestRender(t *testing.T) {
ctx := newTestContext("rendering")
defer ctx.Close()
hello := &Hello{}
ctx.Mount(hello)
hello.Greeting = "Maxence"
Render(hello)
}
func TestRenderPanicCompoCtxError(t *testing.T) {
defer func() { recover() }()
hello := &Hello{}
Render(hello)
t.Error("should panic")
}
func TestRenderSyncError(t *testing.T) {
ctx := newTestContext("rendering")
defer ctx.Close()
hello := &Hello{}
ctx.Mount(hello)
hello.BadMarkupSync = true
Render(hello)
}
func TestMenuBar(t *testing.T) {
t.Log(MenuBar())
}
func TestDock(t *testing.T) {
t.Log(Dock())
}
func TestStorage(t *testing.T) {
t.Log(Storage())
t.Log(Resources())
}