github.com/elves/elvish@v0.15.0/pkg/cli/write_listing_test.go (about)

     1  package cli
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/elves/elvish/pkg/cli/term"
     8  	"github.com/elves/elvish/pkg/ui"
     9  )
    10  
    11  func TestWriteListing(t *testing.T) {
    12  	b := term.NewBufferBuilder(10)
    13  	WriteListing(
    14  		b, " LIST ", "f",
    15  		"line 1",
    16  		"line 2", Selected,
    17  		"line 3")
    18  	buf := b.Buffer()
    19  	wantBuf := term.NewBufferBuilder(10).
    20  		WriteStyled(ModeLine(" LIST ", true)).
    21  		Write("f").SetDotHere().
    22  		Newline().Write("line 1").
    23  		Newline().Write("line 2    ", ui.Inverse).
    24  		Newline().Write("line 3").
    25  		Buffer()
    26  	if !reflect.DeepEqual(buf, wantBuf) {
    27  		t.Errorf("Buf differs")
    28  		t.Logf("Got: %s", buf.TTYString())
    29  		t.Logf("Want: %s", wantBuf.TTYString())
    30  	}
    31  }