-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
83 lines (61 loc) · 1.77 KB
/
config_test.go
File metadata and controls
83 lines (61 loc) · 1.77 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
package forgeui
import "testing"
func TestDefaultConfig(t *testing.T) {
cfg := DefaultConfig()
if cfg.Debug {
t.Error("expected Debug to be false by default")
}
if cfg.Theme != "default" {
t.Errorf("expected Theme to be 'default', got %v", cfg.Theme)
}
if cfg.StaticPath != "/static" {
t.Errorf("expected StaticPath to be '/static', got %v", cfg.StaticPath)
}
if cfg.AssetsPath != "public" {
t.Errorf("expected AssetsPath to be 'public', got %v", cfg.AssetsPath)
}
if cfg.DefaultSize != SizeMD {
t.Errorf("expected DefaultSize to be SizeMD, got %v", cfg.DefaultSize)
}
if cfg.DefaultVariant != VariantDefault {
t.Errorf("expected DefaultVariant to be VariantDefault, got %v", cfg.DefaultVariant)
}
if cfg.DefaultRadius != RadiusMD {
t.Errorf("expected DefaultRadius to be RadiusMD, got %v", cfg.DefaultRadius)
}
}
func TestConfigOptions(t *testing.T) {
cfg := DefaultAppConfig()
WithDebug(true)(cfg)
if !cfg.Debug {
t.Error("WithDebug(true) did not set Debug to true")
}
WithThemeName("dark")(cfg)
if cfg.Theme != "dark" {
t.Errorf("WithThemeName('dark') did not set Theme, got %v", cfg.Theme)
}
WithStaticPath("/assets")(cfg)
if cfg.StaticPath != "/assets" {
t.Errorf("WithStaticPath('/assets') did not set StaticPath, got %v", cfg.StaticPath)
}
WithDefaultSize(SizeLG)(cfg)
if cfg.DefaultSize != SizeLG {
t.Errorf("WithDefaultSize(SizeLG) did not set DefaultSize, got %v", cfg.DefaultSize)
}
}
func TestNew(t *testing.T) {
app := New(
WithDebug(true),
WithThemeName("custom"),
)
cfg := app.Config()
if !cfg.Debug {
t.Error("expected Debug to be true")
}
if cfg.Theme != "custom" {
t.Errorf("expected Theme to be 'custom', got %v", cfg.Theme)
}
if !app.IsDev() {
t.Error("IsDev() should return true when Debug is true")
}
}