elvish/pkg/cli/write_listing_test.go

32 lines
636 B
Go
Raw Normal View History

2019-12-26 08:52:22 +08:00
package cli
import (
"reflect"
"testing"
"src.elv.sh/pkg/cli/term"
"src.elv.sh/pkg/ui"
)
func TestWriteListing(t *testing.T) {
b := term.NewBufferBuilder(10)
WriteListing(
b, " LIST ", "f",
"line 1",
"line 2", Selected,
"line 3")
buf := b.Buffer()
wantBuf := term.NewBufferBuilder(10).
WriteStyled(ModeLine(" LIST ", true)).
Write("f").SetDotHere().
Newline().Write("line 1").
Newline().Write("line 2 ", ui.Inverse).
Newline().Write("line 3").
Buffer()
if !reflect.DeepEqual(buf, wantBuf) {
t.Errorf("Buf differs")
t.Logf("Got: %s", buf.TTYString())
t.Logf("Want: %s", wantBuf.TTYString())
}
}