mirror of
https://github.com/charmbracelet/lipgloss.git
synced 2024-11-23 14:26:29 +03:00
feat(test): add test for JoinHorizontal
(#346)
* refactor: use position constants * test: add test for JoinHorizontal
This commit is contained in:
parent
ed7f56e2a7
commit
0618c73743
25
join_test.go
25
join_test.go
@ -9,8 +9,8 @@ func TestJoinVertical(t *testing.T) {
|
||||
expected string
|
||||
}
|
||||
tests := []test{
|
||||
{"pos0", JoinVertical(0, "A", "BBBB"), "A \nBBBB"},
|
||||
{"pos1", JoinVertical(1, "A", "BBBB"), " A\nBBBB"},
|
||||
{"pos0", JoinVertical(Left, "A", "BBBB"), "A \nBBBB"},
|
||||
{"pos1", JoinVertical(Right, "A", "BBBB"), " A\nBBBB"},
|
||||
{"pos0.25", JoinVertical(0.25, "A", "BBBB"), " A \nBBBB"},
|
||||
}
|
||||
|
||||
@ -22,3 +22,24 @@ func TestJoinVertical(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJoinHorizontal(t *testing.T) {
|
||||
type test struct {
|
||||
name string
|
||||
result string
|
||||
expected string
|
||||
}
|
||||
tests := []test{
|
||||
{"pos0", JoinHorizontal(Top, "A", "B\nB\nB\nB"), "AB\n B\n B\n B"},
|
||||
{"pos1", JoinHorizontal(Bottom, "A", "B\nB\nB\nB"), " B\n B\n B\nAB"},
|
||||
{"pos0.25", JoinHorizontal(0.25, "A", "B\nB\nB\nB"), " B\nAB\n B\n B"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if test.result != test.expected {
|
||||
t.Errorf("Got \n%s\n, expected \n%s\n", test.result, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user