Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98a3bf16cd |
No files matched your search
+1
-7
@@ -402,16 +402,10 @@ func (a *App) cmdQuery(nick string) {
|
|||||||
a.mu.Lock()
|
a.mu.Lock()
|
||||||
a.target = nick
|
a.target = nick
|
||||||
myNick := a.nick
|
myNick := a.nick
|
||||||
connected := a.connected
|
|
||||||
a.mu.Unlock()
|
a.mu.Unlock()
|
||||||
|
|
||||||
connStatus := "disconnected"
|
|
||||||
if connected {
|
|
||||||
connStatus = "connected"
|
|
||||||
}
|
|
||||||
|
|
||||||
a.ui.SwitchToBuffer(nick)
|
a.ui.SwitchToBuffer(nick)
|
||||||
a.ui.SetStatus(myNick, nick, connStatus)
|
a.ui.SetStatus(myNick, nick, "connected")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) cmdTopic(args string) {
|
func (a *App) cmdTopic(args string) {
|
||||||
|
|||||||
@@ -23,13 +23,6 @@ const (
|
|||||||
testText = "hello"
|
testText = "hello"
|
||||||
)
|
)
|
||||||
|
|
||||||
// What the status bar shows while the client is connected, and
|
|
||||||
// while it is not.
|
|
||||||
const (
|
|
||||||
statusConnected = "[connected]"
|
|
||||||
statusDisconnected = "[disconnected]"
|
|
||||||
)
|
|
||||||
|
|
||||||
// eventLoopTimeout is how long a test waits for a typed line to
|
// eventLoopTimeout is how long a test waits for a typed line to
|
||||||
// be handled, for the welcome lines, for the UI to stop, for a poll
|
// be handled, for the welcome lines, for the UI to stop, for a poll
|
||||||
// or for a poll loop to end, before it fails.
|
// or for a poll loop to end, before it fails.
|
||||||
@@ -368,46 +361,6 @@ func TestWindowConnectionState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestQueryConnectionState checks that typing /query bob leaves the
|
|
||||||
// status bar showing [connected] only while the client is connected,
|
|
||||||
// and [disconnected] otherwise.
|
|
||||||
func TestQueryConnectionState(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
const line = "/query " + testOtherNick
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
connected bool
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
{name: "not connected", connected: false, want: statusDisconnected},
|
|
||||||
{name: "connected", connected: true, want: statusConnected},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
app := &App{ui: NewUI(), nick: testNick, connected: test.connected}
|
|
||||||
handled := handledLines(app)
|
|
||||||
runUI(t, app.ui)
|
|
||||||
|
|
||||||
for _, r := range line {
|
|
||||||
app.ui.app.QueueEvent(tcell.NewEventKey(tcell.KeyRune, r, tcell.ModNone))
|
|
||||||
}
|
|
||||||
|
|
||||||
app.ui.app.QueueEvent(tcell.NewEventKey(tcell.KeyEnter, 0, tcell.ModNone))
|
|
||||||
waitHandled(t, handled, line)
|
|
||||||
|
|
||||||
status := statusBarText(app.ui)
|
|
||||||
if !strings.Contains(status, test.want) {
|
|
||||||
t.Fatalf("status bar is %q, want it to show %s", status, test.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestEventLoopKeepsRunning sends Alt and 1, then a typed line and
|
// TestEventLoopKeepsRunning sends Alt and 1, then a typed line and
|
||||||
// Enter, to a running UI. It checks that both are handled, so the
|
// Enter, to a running UI. It checks that both are handled, so the
|
||||||
// event loop did not stop on either.
|
// event loop did not stop on either.
|
||||||
|
|||||||
Reference in new issue
Block a user