-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkey_handling_test.go
43 lines (37 loc) · 940 Bytes
/
key_handling_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import "testing"
func TestSwitchingFocusTooFarLeft(t *testing.T) {
state := NewAppState([]string{"One"}, 10, 10)
state = KeyPress{Key: "<backspace>"}.Apply(state)
if state.selected != 0 {
t.Fail()
}
}
func TestSwitchingFocusToRight(t *testing.T) {
state := NewAppState([]string{"One"}, 10, 10)
state.layout = 2
state = KeyPress{Key: "C-l"}.Apply(state)
if state.selected != 1 {
t.Fail()
}
}
func TestChangingLayout(t *testing.T) {
fileNames := []string{"1"}
state := NewAppState(fileNames, 10, 10)
state = KeyPress{Key: "2"}.Apply(state)
if state.layout != 2 {
t.Fail()
}
}
func TestSpaceTogglesmodifier(t *testing.T) {
state := NewAppState([]string{"1"}, 10, 10)
state.CurrentMode = modifierMode
state.modifiers = modifiers{
modifier{active: false},
}
state.selectedMod = 0
state = KeyPress{Key: "<space>"}.Apply(state)
if state.modifiers[state.selectedMod].active != true {
t.Fail()
}
}