Extract mpv/key to input

To separate the concern from `mpv`
This commit is contained in:
Alexander Heldt
2025-11-18 18:39:20 +01:00
parent 417b5a2559
commit 1c47a84750
6 changed files with 7 additions and 7 deletions

View File

@@ -0,0 +1,29 @@
import gleam/list
import gleeunit
import input/key.{type Key, Char, csi, esc}
pub fn main() -> Nil {
gleeunit.main()
}
type TestCase {
TestCase(input: List(String), expected: Key)
}
pub fn key_from_list_test() {
let test_cases = [
TestCase(["c"], Char("c")),
TestCase([esc, csi, "D"], key.Left),
TestCase([esc, csi, "C"], key.Right),
TestCase([esc, csi, "A"], key.Up),
TestCase([esc, csi, "B"], key.Down),
TestCase([esc, csi], key.Continue),
TestCase([esc], key.Continue),
TestCase([], key.Continue),
]
list.each(test_cases, fn(tc) {
assert tc.expected == key.from_list(tc.input)
})
}