Skip to content

Commit

Permalink
refactor(tree): clarify SetValue usage in test
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Jan 10, 2025
1 parent 0cdf875 commit 8cd37f1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tree/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/tree"
"github.com/charmbracelet/x/ansi"
)

// Leaf Examples
Expand Down Expand Up @@ -67,7 +68,7 @@ func ExampleNewLeaf() {
//
}

func ExampleSetValue() {
func ExampleLeaf_SetValue() {
enumeratorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("63")).MarginRight(1)
rootStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("35"))
itemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
Expand All @@ -90,10 +91,17 @@ func ExampleSetValue() {
RootStyle(rootStyle).
ItemStyle(itemStyle)
glossier := t.Children().At(0)
glossier.SetValue(tree.Root(glossier.Value()).Child(tree.Root("Apparel").Child("Pink Hoodie", "Baseball Cap")))
fmt.Println(t.String())
glossier.SetValue("Il Makiage")
fmt.Println(ansi.Strip(t.String()))
// Output:
// hello
//⁜ Makeup
//β”œβ”€β”€ Il Makiage
//β”œβ”€β”€ Fenty Beauty
//β”‚ β”œβ”€β”€ Gloss Bomb Universal Lip Luminizer
//β”‚ ╰── Hot Cheeks Velour Blushlighter
//β”œβ”€β”€ Nyx
//β”œβ”€β”€ Mac
//╰── Milk
}

// Tree Examples
Expand Down

0 comments on commit 8cd37f1

Please sign in to comment.