-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcomponent_test.go
More file actions
44 lines (33 loc) 路 838 Bytes
/
Copy pathcomponent_test.go
File metadata and controls
44 lines (33 loc) 路 838 Bytes
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
package reactea
import (
"bytes"
"strings"
"testing"
"time"
tea "github.com/charmbracelet/bubbletea"
)
func TestDefaultComponent(t *testing.T) {
var out bytes.Buffer
component := &mockComponent[struct{}]{
renderFunc: func(c Component, s *struct{}, width, height int) string {
return "test passed"
},
}
program := NewProgram(component, WithoutInput(), tea.WithOutput(&out))
go func() {
time.Sleep(20 * time.Millisecond)
program.Quit()
}()
if _, err := program.Run(); err != nil {
t.Fatal(err)
}
if !strings.Contains(out.String(), "test passed") {
t.Errorf("invalid output, got \"%s\"", out.String())
}
}
func TestInvisibleComponent(t *testing.T) {
component := &InvisibleComponent{}
if result := component.Render(1, 1); result != "" {
t.Errorf("expected empty string, got \"%s\"", result)
}
}