bubbles/key/key_test.go
Hironao OTSUBO e49b5573bc
fix(key): Unbound keys should be disabled
* fix condition for #188
This is a fix of https://github.com/charmbracelet/bubbles/pull/188
Unbound keys has nil keys and they are not Enabled
2022-07-11 10:45:18 -04:00

27 lines
447 B
Go

package key
import (
"testing"
)
func TestBinding_Enabled(t *testing.T) {
binding := NewBinding(
WithKeys("k", "up"),
WithHelp("↑/k", "move up"),
)
if !binding.Enabled() {
t.Errorf("expected key to be Enabled")
}
binding.SetEnabled(false)
if binding.Enabled() {
t.Errorf("expected key not to be Enabled")
}
binding.SetEnabled(true)
binding.Unbind()
if binding.Enabled() {
t.Errorf("expected key not to be Enabled")
}
}