Skip to content

Commit

Permalink
fix: bash's issue
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed May 15, 2024
1 parent 52d2d64 commit cce303c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func (n *List) Item(item any) *List {

// Items add multiple items to the tree.
func (n *List) Items(items ...any) *List {
n.inner.Items(items)
for _, item := range items {
n.Item(item)
}
return n
}

Expand Down
28 changes: 25 additions & 3 deletions list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,29 @@ LXXXVIII. Foo
XCIX. Foo
C. Foo`, "\n")

if l.String() != expected {
t.Fatalf("expected:\n\n%s\n\ngot:\n\n%s\n", expected, l.String())
}
require.Equal(t, expected, l.String())
}

func TestSubListItems(t *testing.T) {
l := list.New().Items(
"S",
list.New().Items("neovim", "vscode"),
"HI",
list.New().Items([]string{"vim", "doom emacs"}),
"Parent 2",
list.New().Item("I like fuzzy socks"),
)

expected := `
• S
• neovim
• vscode
• HI
• vim
• doom emacs
• Parent 2
• I like fuzzy socks
`

require.Equal(t, expected, l.String())
}

0 comments on commit cce303c

Please sign in to comment.