Partial implementation of Tasks and Logs and test refactor
This commit is contained in:
+4
-84
@@ -3,6 +3,10 @@ use std::fmt::{Display, Formatter};
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "key_tests.rs"]
|
||||
mod key_tests;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Key {
|
||||
Up,
|
||||
@@ -76,87 +80,3 @@ impl From<KeyEvent> for Key {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
|
||||
use crate::event::key::Key;
|
||||
|
||||
#[test]
|
||||
fn test_key_formatter() {
|
||||
assert_str_eq!(format!("{}", Key::Esc), "<Esc>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_formatter_char() {
|
||||
assert_str_eq!(format!("{}", Key::Char('q')), "<q>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_up() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Up)), Key::Up);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_down() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Down)), Key::Down);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_left() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Left)), Key::Left);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_right() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Right)), Key::Right);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_backspace() {
|
||||
assert_eq!(
|
||||
Key::from(KeyEvent::from(KeyCode::Backspace)),
|
||||
Key::Backspace
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_home() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Home)), Key::Home);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_end() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::End)), Key::End);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_delete() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Delete)), Key::Delete);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_enter() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Enter)), Key::Enter);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_esc() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Esc)), Key::Esc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_char() {
|
||||
assert_eq!(
|
||||
Key::from(KeyEvent::from(KeyCode::Char('q'))),
|
||||
Key::Char('q')
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_unknown() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Pause)), Key::Unknown);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
|
||||
use crate::event::key::Key;
|
||||
|
||||
#[test]
|
||||
fn test_key_formatter() {
|
||||
assert_str_eq!(format!("{}", Key::Esc), "<Esc>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_formatter_char() {
|
||||
assert_str_eq!(format!("{}", Key::Char('q')), "<q>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_up() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Up)), Key::Up);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_down() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Down)), Key::Down);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_left() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Left)), Key::Left);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_right() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Right)), Key::Right);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_backspace() {
|
||||
assert_eq!(
|
||||
Key::from(KeyEvent::from(KeyCode::Backspace)),
|
||||
Key::Backspace
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_home() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Home)), Key::Home);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_end() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::End)), Key::End);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_delete() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Delete)), Key::Delete);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_enter() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Enter)), Key::Enter);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_esc() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Esc)), Key::Esc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_char() {
|
||||
assert_eq!(
|
||||
Key::from(KeyEvent::from(KeyCode::Char('q'))),
|
||||
Key::Char('q')
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_key_from_unknown() {
|
||||
assert_eq!(Key::from(KeyEvent::from(KeyCode::Pause)), Key::Unknown);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user