Files
musicplayer/test/mpv/control_test.gleam
Alexander Heldt 3fb92d4654 wip
2025-11-16 16:12:19 +01:00

34 lines
748 B
Gleam

import gleam/list
import gleeunit
import mpv/control.{type Control}
import mpv/internal/control as control_internal
import mpv/key.{type Key, Char}
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"
let assert Ok(data) = control_internal.parse_playback_time(json_string)
assert data == 123.456789
}