Unittest keylist (#1545)

* fix warning
* add unittest to keylist
This commit is contained in:
extrawurst 2023-02-15 00:20:45 +00:00 committed by GitHub
parent aefc18d819
commit d4d6fd28eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 1 deletions

1
Cargo.lock generated
View file

@ -786,6 +786,7 @@ dependencies = [
"serde",
"simplelog",
"syntect",
"tempfile",
"textwrap",
"tui",
"unicode-segmentation",

View file

@ -61,6 +61,7 @@ pprof = { version = "0.11", features = ["flamegraph"], optional = true }
[dev-dependencies]
pretty_assertions = "1.3"
tempfile = "3.2"
[badges]
maintenance = { status = "actively-developed" }

View file

@ -226,7 +226,7 @@ impl StatusTreeComponent {
}
}
/// Returns a Vec<TextDrawInfo> which is used to draw the `FileTreeComponent` correctly,
/// Returns a `Vec<TextDrawInfo>` which is used to draw the `FileTreeComponent` correctly,
/// allowing folders to be folded up if they are alone in their directory
fn build_vec_text_draw_info_for_drawing(
&self,

View file

@ -210,3 +210,37 @@ impl KeysList {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
use std::io::Write;
use tempfile::NamedTempFile;
#[test]
fn test_smoke() {
let mut file = NamedTempFile::new().unwrap();
writeln!(
file,
r"
(
move_down: Some(( code: Char('j'), modifiers: ( bits: 2,),)),
)
"
)
.unwrap();
let keys = KeysList::init(file.path().to_path_buf());
assert_eq!(keys.move_right, KeysList::default().move_right);
assert_eq!(
keys.move_down,
GituiKeyEvent::new(
KeyCode::Char('j'),
KeyModifiers::CONTROL
)
);
}
}