Skip to content

Commit

Permalink
test(tree): add TestInheritedStyles for items added to existing Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Jan 10, 2025
1 parent f03f016 commit cc34602
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tree/testdata/TestInheritedStyles.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
⁜ Makeup
β”œβ”€β”€ Glossier
β”‚  β”œβ”€β”€ Apparel
β”‚  β”‚  β”œβ”€β”€ Pink Hoodie
β”‚  β”‚  ╰── Baseball Cap
β”‚  ╰── Makeup
β”œβ”€β”€ Fenty Beauty
β”‚  β”œβ”€β”€ Gloss Bomb Universal Lip Luminizer
β”‚  ╰── Hot Cheeks Velour Blushlighter
β”œβ”€β”€ Nyx
β”œβ”€β”€ Mac
╰── Milk
32 changes: 32 additions & 0 deletions tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,38 @@ func TestRootStyle(t *testing.T) {
golden.RequireEqual(t, []byte(tree.String()))
}

func TestInheritedStyles(t *testing.T) {
enumeratorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("63")).MarginRight(1)
rootStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("35"))
itemStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("212"))

tr := tree.
Root("⁜ Makeup").
Child(
"Glossier",
"Fenty Beauty",
tree.New().Child(
"Gloss Bomb Universal Lip Luminizer",
"Hot Cheeks Velour Blushlighter",
),
"Nyx",
"Mac",
"Milk",
).
Enumerator(tree.RoundedEnumerator).
EnumeratorStyle(enumeratorStyle).
RootStyle(rootStyle).
ItemStyle(itemStyle)
// Add a Tree as a Child of "Glossier"
tr.Replace(0, tr.Children().At(0).Child(
tree.Root("Apparel").Child("Pink Hoodie", "Baseball Cap"),
))

// Add a Leaf as a Child of "Glossier"
tr.Children().At(0).Child("Makeup")
golden.RequireEqual(t, []byte(tr.String()))
}

func TestAt(t *testing.T) {
data := tree.NewStringData("Foo", "Bar")

Expand Down

0 comments on commit cc34602

Please sign in to comment.