-
-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy pathwidget_maker_test.go
77 lines (71 loc) · 1.35 KB
/
widget_maker_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package app
import (
"testing"
"github.com/olebedev/config"
"github.com/stretchr/testify/assert"
"github.com/wtfutil/wtf/modules/clocks"
"github.com/wtfutil/wtf/wtf"
)
const (
disabled = `
wtf:
mods:
clocks:
enabled: false
position:
top: 0
left: 0
height: 1
width: 1
refreshInterval: 30`
enabled = `
wtf:
mods:
clocks:
enabled: true
position:
top: 0
left: 0
height: 1
width: 1
refreshInterval: 30`
)
func Test_MakeWidget(t *testing.T) {
tests := []struct {
name string
moduleName string
config *config.Config
expected wtf.Wtfable
}{
{
name: "invalid module",
moduleName: "",
config: &config.Config{},
expected: nil,
},
{
name: "valid disabled module",
moduleName: "clocks",
config: func() *config.Config {
cfg, _ := config.ParseYaml(disabled)
return cfg
}(),
expected: nil,
},
{
name: "valid enabled module",
moduleName: "clocks",
config: func() *config.Config {
cfg, _ := config.ParseYaml(enabled)
return cfg
}(),
expected: &clocks.Widget{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := MakeWidget(nil, nil, tt.moduleName, tt.config, make(chan bool))
assert.IsType(t, tt.expected, actual)
})
}
}