2019-11-16 18:30:25 +08:00
|
|
|
package layout
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
2019-11-26 07:28:05 +08:00
|
|
|
"github.com/elves/elvish/cli/term"
|
2019-11-16 18:30:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWriteListing(t *testing.T) {
|
2019-11-26 07:28:05 +08:00
|
|
|
b := term.NewBufferBuilder(10)
|
2019-11-16 18:30:25 +08:00
|
|
|
WriteListing(
|
|
|
|
b, " LIST ", "f",
|
|
|
|
"line 1",
|
|
|
|
"line 2", Selected,
|
|
|
|
"line 3")
|
|
|
|
buf := b.Buffer()
|
2019-11-26 07:28:05 +08:00
|
|
|
wantBuf := term.NewBufferBuilder(10).
|
2019-11-16 18:30:25 +08:00
|
|
|
WriteStyled(ModeLine(" LIST ", true)).
|
2019-11-26 05:51:14 +08:00
|
|
|
Write("f").SetDotHere().
|
|
|
|
Newline().Write("line 1").
|
|
|
|
Newline().Write("line 2 ", "inverse").
|
|
|
|
Newline().Write("line 3").
|
2019-11-16 18:30:25 +08:00
|
|
|
Buffer()
|
|
|
|
if !reflect.DeepEqual(buf, wantBuf) {
|
|
|
|
t.Errorf("Buf differs")
|
|
|
|
t.Logf("Got: %s", buf.TTYString())
|
|
|
|
t.Logf("Want: %s", wantBuf.TTYString())
|
|
|
|
}
|
|
|
|
}
|