From 9a81a77fb35fd2ac7b744d13c1de8dd8a070575e Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Wed, 15 Sep 2021 16:42:16 +0900 Subject: [PATCH] add tests --- src/app.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index de45866..5aa333f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -136,6 +136,9 @@ impl App { CommandInfo::new(command::filter(&self.config.key_config)), CommandInfo::new(command::help(&self.config.key_config)), CommandInfo::new(command::toggle_tabs(&self.config.key_config)), + CommandInfo::new(command::extend_or_shorten_widget_width( + &self.config.key_config, + )), ]; self.databases.commands(&mut res); @@ -500,17 +503,33 @@ impl App { mod test { use super::{App, Config, EventState, Key}; + #[test] fn test_extend_or_shorten_widget_width() { let mut app = App::new(Config::default()); assert_eq!( - app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(), + app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(), EventState::Consumed ); - aasert_eq!(app.left_chunk_percentage, ) + assert_eq!(app.left_chunk_percentage, 20); + app.left_chunk_percentage = 70; assert_eq!( app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(), EventState::Consumed ); + assert_eq!(app.left_chunk_percentage, 70); + + assert_eq!( + app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(), + EventState::Consumed + ); + assert_eq!(app.left_chunk_percentage, 65); + + app.left_chunk_percentage = 15; + assert_eq!( + app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(), + EventState::Consumed + ); + assert_eq!(app.left_chunk_percentage, 15); } }