Repository navigation
Expand file tree
/
Copy pathnavigation_test.go
More file actions
72 lines (61 loc) · 1.8 KB
/
Copy pathnavigation_test.go
File metadata and controls
72 lines (61 loc) · 1.8 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
package main
import (
"strings"
"testing"
"github.com/rivo/tview"
)
func TestHelpBarTextForConversations(t *testing.T) {
text := helpBarText(TrChat)
if !strings.Contains(text, "Tree") {
t.Fatalf("expected conversations help text, got %q", text)
}
}
func TestHelpBarTextForMessages(t *testing.T) {
text := helpBarText(ViChat)
if !strings.Contains(text, "Msgs") {
t.Fatalf("expected messages help text, got %q", text)
}
}
func TestHelpBarTextIsCompact(t *testing.T) {
for _, focused := range []string{TrChat, ViChat} {
text := helpBarText(focused)
if strings.Contains(text, "\n") {
t.Fatalf("expected single-line help bar text, got %q", text)
}
}
}
func TestFindParentNode(t *testing.T) {
root := tview.NewTreeNode("root")
child := tview.NewTreeNode("child")
leaf := tview.NewTreeNode("leaf")
root.AddChild(child)
child.AddChild(leaf)
parent := findParentNode(root, leaf)
if parent != child {
t.Fatalf("expected parent %p, got %p", child, parent)
}
}
func TestFirstSelectableChildReturnsFirstChild(t *testing.T) {
root := tview.NewTreeNode("root")
child := tview.NewTreeNode("child")
root.AddChild(child)
got := firstSelectableChild(root)
if got != child {
t.Fatalf("expected first child %p, got %p", child, got)
}
}
func TestConversationHintTextForChats(t *testing.T) {
mainText, secondaryText := conversationHintText(tview.NewTreeNode("Chats"))
if !strings.Contains(mainText, "chat") {
t.Fatalf("expected chat hint, got %q", mainText)
}
if !strings.Contains(secondaryText, "Enter") {
t.Fatalf("expected navigation hint, got %q", secondaryText)
}
}
func TestConversationHintTextForTeam(t *testing.T) {
mainText, _ := conversationHintText(tview.NewTreeNode("CyberSec"))
if !strings.Contains(mainText, "CyberSec") {
t.Fatalf("expected team-specific hint, got %q", mainText)
}
}