All checks were successful
continuous-integration/drone/push Build is passing
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package ui
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHandleCommandTypes(t *testing.T) {
|
|
tests := []struct {
|
|
cmdInput string
|
|
hiddenInput string
|
|
cmdOutput interface{}
|
|
}{
|
|
{"help", "", cmdMsg{}},
|
|
{"quit", "", turnAcnOffMsg{}},
|
|
{"start", "", showGettingStartedGuideMsg{}},
|
|
{"profile unlock foo", "", profileUnlockMsg{}},
|
|
{"profile info", "", profileInfoMsg{}},
|
|
{"profile create foo *** ***", "bar bar", profileCreateMsg{}},
|
|
{"acn on", "", turnAcnOnMsg{}},
|
|
{"acn off", "", turnAcnOffMsg{}},
|
|
{"clear", "", clearScreenMsg{}},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
msg := handleCommand(test.cmdInput, test.hiddenInput)
|
|
switch msg := msg.(type) {
|
|
default:
|
|
assert.IsType(t, msg, test.cmdOutput)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestHandleCommandUnknownCommand(t *testing.T) {
|
|
msg := handleCommand("foo", "")
|
|
switch msg := msg.(type) {
|
|
case cmdMsg:
|
|
assert.Equal(t, msg.output, []string{unknownCmdHelp})
|
|
default:
|
|
assert.IsType(t, msg, cmdMsg{})
|
|
}
|
|
}
|
|
|
|
func TestHandleCommandIncorrectCommand(t *testing.T) {
|
|
msg := handleCommand("profile foo", "")
|
|
switch msg := msg.(type) {
|
|
case cmdMsg:
|
|
assert.Contains(t, msg.output, `Unknown "profile" command?`)
|
|
default:
|
|
assert.IsType(t, msg, cmdMsg{})
|
|
}
|
|
}
|