mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
32 lines
636 B
Go
32 lines
636 B
Go
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())
|
|
}
|
|
}
|