Fix Output Device toggle
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package page
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMoveFocus(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
current int
|
||||
delta int
|
||||
want int
|
||||
}{
|
||||
{"down from track goes to device", 0, 1, 1},
|
||||
{"down from device goes to toggle", 1, 1, focusToggle},
|
||||
{"down from toggle stays", focusToggle, 1, focusToggle},
|
||||
{"up from toggle goes to device", focusToggle, -1, 1},
|
||||
{"up from device goes to track", 1, -1, 0},
|
||||
{"up from track stays", 0, -1, 0},
|
||||
{"down does not overshoot below toggle", focusToggle, 5, focusToggle},
|
||||
{"up does not undershoot above track", 0, -5, 0},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := moveFocus(tt.current, tt.delta); got != tt.want {
|
||||
t.Errorf("moveFocus(%d, %d) = %d, want %d", tt.current, tt.delta, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user