This commit is contained in:
Alexander Heldt
2025-11-21 21:41:49 +01:00
parent 249b0671e4
commit b364431669
9 changed files with 263 additions and 111 deletions

View File

@@ -1,29 +1,11 @@
import gleam/list
import gleeunit
import input/key.{type Key, Char}
import mpv/control.{type Control}
import mpv/internal as control_internal
pub fn main() -> Nil {
gleeunit.main()
}
type TestCase {
TestCase(key: Key, expected: Result(Control, Nil))
}
pub fn control_from_key_test() {
let test_cases = [
TestCase(Char(" "), Ok(control.TogglePlayPause)),
TestCase(Char("q"), Ok(control.Exit)),
]
list.each(test_cases, fn(tc) {
assert tc.expected == control.from_key(tc.key)
})
}
pub fn parse_playback_time_test() {
let json_string =
"{\"data\":\"123.456789\",\"request_id\":0,\"error\":\"success\"}\n"

24
test/ui/ui_test.gleam Normal file
View File

@@ -0,0 +1,24 @@
import gleam/list
import gleeunit
import input/key.{type Key, Char}
import ui/control.{type Control}
pub fn main() -> Nil {
gleeunit.main()
}
type TestCase {
TestCase(key: Key, expected: Result(Control, Nil))
}
pub fn control_from_key_test() {
let test_cases = [
TestCase(Char(" "), Ok(control.TogglePlayPause)),
TestCase(Char("q"), Ok(control.Exit)),
]
list.each(test_cases, fn(tc) {
assert tc.expected == control.from_key(tc.key)
})
}