1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

better formatting

This commit is contained in:
Jesse Duffield
2021-10-31 22:29:43 +11:00
parent f91892b8f1
commit 9989c96321
4 changed files with 110 additions and 29 deletions

View File

@ -37,27 +37,6 @@ func TestWithPadding(t *testing.T) {
}
}
// TestGetPaddedDisplayStrings is a function.
func TestGetPaddedDisplayStrings(t *testing.T) {
type scenario struct {
stringArrays [][]string
padWidths []int
expected []string
}
scenarios := []scenario{
{
[][]string{{"a", "b"}, {"c", "d"}},
[]int{1},
[]string{"a b", "c d"},
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, getPaddedDisplayStrings(s.stringArrays, s.padWidths))
}
}
func TestGetPadWidths(t *testing.T) {
type scenario struct {
input [][]string
@ -162,3 +141,44 @@ func TestTruncateWithEllipsis(t *testing.T) {
assert.EqualValues(t, s.expected, TruncateWithEllipsis(s.str, s.limit))
}
}
func TestRenderDisplayStrings(t *testing.T) {
type scenario struct {
input [][]string
expected string
}
tests := []scenario{
{
[][]string{{""}, {""}},
"",
},
{
[][]string{{"a"}, {""}},
"a\n",
},
{
[][]string{{"a"}, {"b"}},
"a\nb",
},
{
[][]string{{"a", "b"}, {"c", "d"}},
"a b\nc d",
},
{
[][]string{{"a", "", "c"}, {"d", "", "f"}},
"a c\nd f",
},
{
[][]string{{"a", "", "c", ""}, {"d", "", "f", ""}},
"a c\nd f",
},
}
for _, test := range tests {
output := RenderDisplayStrings(test.input)
if !assert.EqualValues(t, output, test.expected) {
t.Errorf("RenderDisplayStrings(%v) = %v, want %v", test.input, output, test.expected)
}
}
}