mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
40 lines
983 B
Go
40 lines
983 B
Go
package textinput
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_CurrentSuggestion(t *testing.T) {
|
|
textinput := New()
|
|
textinput.ShowSuggestions = true
|
|
|
|
suggestion := textinput.CurrentSuggestion()
|
|
expected := ""
|
|
if suggestion != expected {
|
|
t.Fatalf("Error: expected no current suggestion but was %s", suggestion)
|
|
}
|
|
|
|
textinput.SetSuggestions([]string{"test1", "test2", "test3"})
|
|
suggestion = textinput.CurrentSuggestion()
|
|
expected = ""
|
|
if suggestion != expected {
|
|
t.Fatalf("Error: expected no current suggestion but was %s", suggestion)
|
|
}
|
|
|
|
textinput.SetValue("test")
|
|
textinput.updateSuggestions()
|
|
textinput.nextSuggestion()
|
|
suggestion = textinput.CurrentSuggestion()
|
|
expected = "test2"
|
|
if suggestion != expected {
|
|
t.Fatalf("Error: expected first suggestion but was %s", suggestion)
|
|
}
|
|
}
|
|
|
|
func Test_SlicingOutsideCap(t *testing.T) {
|
|
textinput := New()
|
|
textinput.Placeholder = "作業ディレクトリを指定してください"
|
|
textinput.SetWidth(32)
|
|
textinput.View()
|
|
}
|