MCPcopy Create free account
hub / github.com/charmbracelet/bubbles / TestNodeSetValue

Function TestNodeSetValue

tree/node_value_test.go:14–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12func (s nodeValueStringer) String() string { return string(s) }
13
14func TestNodeSetValue(t *testing.T) {
15 for _, test := range []struct {
16 name string
17 value any
18 want string
19 }{
20 {"string", "after", "after"},
21 {"number", 42, "42"},
22 {"stringer", nodeValueStringer("formatted"), "formatted"},
23 } {
24 t.Run(test.name, func(t *testing.T) {
25 node := Root("before").Child("child")
26 node.SetValue(test.value)
27 if got := node.GivenValue(); got != test.value {
28 t.Errorf("GivenValue() = %v, want %v", got, test.value)
29 }
30 if got := ansi.Strip(node.Value()); got != test.want {
31 t.Errorf("Value() = %q, want %q", got, test.want)
32 }
33 wantTree := test.want + "\n└── child"
34 if got := ansi.Strip(node.String()); got != wantTree {
35 t.Errorf("String() = %q, want %q", got, wantTree)
36 }
37 })
38 }
39}
40
41func TestTreeSetChildValue(t *testing.T) {
42 root := Root("root").Child("before")

Callers

nothing calls this directly

Calls 7

nodeValueStringerTypeAlias · 0.85
RootFunction · 0.85
ChildMethod · 0.80
GivenValueMethod · 0.80
SetValueMethod · 0.45
ValueMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected