diff options
Diffstat (limited to 'zellij-client/src/old_config_converter/unit')
36 files changed, 9406 insertions, 0 deletions
diff --git a/zellij-client/src/old_config_converter/unit/convert_config_tests.rs b/zellij-client/src/old_config_converter/unit/convert_config_tests.rs new file mode 100644 index 000000000..444d8775d --- /dev/null +++ b/zellij-client/src/old_config_converter/unit/convert_config_tests.rs @@ -0,0 +1,126 @@ +use crate::old_config_converter::config_yaml_to_config_kdl; +use insta::assert_snapshot; +use std::path::PathBuf; +use std::{fs::File, io::prelude::*}; + +#[test] +fn properly_convert_default_config() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_default_yaml_config.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_custom_options() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_custom_options.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_keybind_unbinds_in_mode() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_unbinds_in_mode.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_global_keybind_unbinds() -> Result<(), String> { + let fixture = PathBuf::from(format!("{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_global_keybind_unbinds.yaml", env!("CARGO_MANIFEST_DIR"))); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_unbind_all_keys_per_mode() -> Result<(), String> { + let fixture = PathBuf::from(format!("{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_unbind_all_keys_per_mode.yaml", env!("CARGO_MANIFEST_DIR"))); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_env_variables() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_env_variables.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_ui_config() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_ui.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn convert_config_with_themes_config() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_config_with_themes.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = config_yaml_to_config_kdl(&raw_config_file, false)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} diff --git a/zellij-client/src/old_config_converter/unit/convert_layout_tests.rs b/zellij-client/src/old_config_converter/unit/convert_layout_tests.rs new file mode 100644 index 000000000..30e689bb1 --- /dev/null +++ b/zellij-client/src/old_config_converter/unit/convert_layout_tests.rs @@ -0,0 +1,142 @@ +use crate::old_config_converter::layout_yaml_to_layout_kdl; +use insta::assert_snapshot; +use std::path::PathBuf; +use std::{fs::File, io::prelude::*}; + +#[test] +fn properly_convert_default_layout() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_default_yaml_layout.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_with_session_name() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_layout_with_session_name.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_with_session_name_and_attach_false() -> Result<(), String> { + let fixture = PathBuf::from(format!("{}/src/old_config_converter/unit/fixtures/old_yaml_layout_with_session_name_and_attach_false.yaml", env!("CARGO_MANIFEST_DIR"))); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_with_config() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/old_yaml_layout_with_config.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_with_config_and_session_name() -> Result<(), String> { + let fixture = PathBuf::from(format!("{}/src/old_config_converter/unit/fixtures/old_yaml_layout_with_config_and_session_name.yaml", env!("CARGO_MANIFEST_DIR"))); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_example_1() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/multiple_tabs_layout.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_example_2() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/multiple_tabs_layout_htop_command.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_example_3() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/run_htop_layout.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} + +#[test] +fn properly_convert_layout_example_4() -> Result<(), String> { + let fixture = PathBuf::from(format!( + "{}/src/old_config_converter/unit/fixtures/run_htop_layout_with_plugins.yaml", + env!("CARGO_MANIFEST_DIR") + )); + let mut handle = File::open(&fixture).map_err(|e| format!("{}", e))?; + let mut raw_config_file = String::new(); + handle + .read_to_string(&mut raw_config_file) + .map_err(|e| format!("{}", e))?; + let kdl_config = layout_yaml_to_layout_kdl(&raw_config_file)?; + assert_snapshot!(format!("{}", kdl_config)); + Ok(()) +} diff --git a/zellij-client/src/old_config_converter/unit/fixtures/multiple_tabs_layout.yaml b/zellij-client/src/old_config_converter/unit/fixtures/multiple_tabs_layout.yaml new file mode 100644 index 000000000..04fca4a51 --- /dev/null +++ b/zellij-client/src/old_config_converter/unit/fixtures/multiple_tabs_layout.yaml @@ -0,0 +1,90 @@ +--- +template: + direction: Horizontal + parts: + - direction: Vertical + split_size: + Fixed: 1 + run: + plugin: + location: "zellij:tab-bar" + borderless: true + - direction: Vertical + body: true + - direction: Vertical + split_size: + Fixed: 2 + run: + plugin: + location: "zellij:status-bar" + borderless: true + +tabs: +- direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Vertical + split_size: + Percent: 50 +- direction: Vertical +- direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Vertical + split_size: + Percent: 50 +- direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Horizontal + split_size: + Percent: 50 + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Vertical + split_size: + Percent: 50 +- direction: Vertical +- direction: Vertical +- direction: Vertical +- direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 20 + run: + plugin: + location: "zellij:strider" + - direction: Horizontal + split_size: + Percent: 80 + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Vertical + split_size: + Percent: 50 +- direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 40 + - direction: Horizontal + split_size: + Percent: 60 + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: |