-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprops_test.go
More file actions
63 lines (49 loc) · 1.05 KB
/
props_test.go
File metadata and controls
63 lines (49 loc) · 1.05 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
package forgeui
import "testing"
type testProps struct {
Value string
Count int
}
func TestApplyOptions(t *testing.T) {
props := &testProps{
Value: "initial",
Count: 0,
}
opts := []Option[testProps]{
func(p *testProps) { p.Value = "updated" },
func(p *testProps) { p.Count = 5 },
}
ApplyOptions(props, opts)
if props.Value != "updated" {
t.Errorf("Value = %v, want 'updated'", props.Value)
}
if props.Count != 5 {
t.Errorf("Count = %v, want 5", props.Count)
}
}
func TestApplyOptions_Empty(t *testing.T) {
props := &testProps{
Value: "initial",
Count: 0,
}
ApplyOptions(props, []Option[testProps]{})
if props.Value != "initial" {
t.Error("Props should not change when no options applied")
}
}
func TestBaseProps(t *testing.T) {
props := BaseProps{
Class: "custom-class",
Disabled: true,
ID: "test-id",
}
if props.Class != "custom-class" {
t.Error("Class not set correctly")
}
if !props.Disabled {
t.Error("Disabled not set correctly")
}
if props.ID != "test-id" {
t.Error("ID not set correctly")
}
}