1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-05-03 22:17:06 +08:00
termdash/terminal/termbox/termbox_test.go
2019-02-10 23:55:35 -05:00

47 lines
937 B
Go

package termbox
import (
"testing"
"github.com/kylelemons/godebug/pretty"
"github.com/mum4k/termdash/eventqueue"
"github.com/mum4k/termdash/terminalapi"
)
func TestNewTerminal(t *testing.T) {
tests := []struct {
desc string
opts []Option
want *Terminal
}{
{
desc: "default options",
want: &Terminal{
events: eventqueue.New(),
done: make(chan struct{}),
colorMode: terminalapi.ColorMode256,
},
},
{
desc: "sets color mode",
opts: []Option{
ColorMode(terminalapi.ColorModeNormal),
},
want: &Terminal{
events: eventqueue.New(),
done: make(chan struct{}),
colorMode: terminalapi.ColorModeNormal,
},
},
}
for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
got := newTerminal(tc.opts...)
if diff := pretty.Compare(tc.want, got); diff != "" {
t.Errorf("newTerminal => unexpected diff (-want, +got):\n%s", diff)
}
})
}
}