diff options
Diffstat (limited to 'zellij-utils/src/input/unit')
4 files changed, 236 insertions, 0 deletions
diff --git a/zellij-utils/src/input/unit/layout_test.rs b/zellij-utils/src/input/unit/layout_test.rs index 1addb9382..9614eef46 100644 --- a/zellij-utils/src/input/unit/layout_test.rs +++ b/zellij-utils/src/input/unit/layout_test.rs @@ -269,6 +269,19 @@ fn layout_with_command_panes_and_cwd_and_args() { } #[test] +fn layout_with_command_panes_and_close_on_exit() { + let kdl_layout = r#" + layout { + pane command="htop" { + close_on_exit true + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None).unwrap(); + assert_snapshot!(format!("{:#?}", layout)); +} + +#[test] fn layout_with_plugin_panes() { let kdl_layout = r#" layout { @@ -1034,6 +1047,24 @@ fn args_override_args_in_template() { } #[test] +fn close_on_exit_overrides_close_on_exit_in_template() { + let kdl_layout = r#" + layout { + pane_template name="tail" { + command "tail" + close_on_exit false + } + tail + tail { + close_on_exit true + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None).unwrap(); + assert_snapshot!(format!("{:#?}", layout)); +} + +#[test] fn args_added_to_args_in_template() { let kdl_layout = r#" layout { @@ -1051,6 +1082,23 @@ fn args_added_to_args_in_template() { } #[test] +fn close_on_exit_added_to_close_on_exit_in_template() { + let kdl_layout = r#" + layout { + pane_template name="tail" { + command "tail" + } + tail + tail { + close_on_exit true + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None).unwrap(); + assert_snapshot!(format!("{:#?}", layout)); +} + +#[test] fn cwd_override_cwd_in_template() { let kdl_layout = r#" layout { @@ -1126,6 +1174,19 @@ fn error_on_bare_args_without_command() { } #[test] +fn error_on_bare_close_on_exit_without_command() { + let kdl_layout = r#" + layout { + pane { + close_on_exit true + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None); + assert!(layout.is_err(), "error provided"); +} + +#[test] fn error_on_bare_args_in_template_without_command() { let kdl_layout = r#" layout { @@ -1140,6 +1201,20 @@ fn error_on_bare_args_in_template_without_command() { } #[test] +fn error_on_bare_close_on_exit_in_template_without_command() { + let kdl_layout = r#" + layout { + pane_template name="my_template" + my_template { + close_on_exit true + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None); + assert!(layout.is_err(), "error provided"); +} + +#[test] fn pane_template_command_with_cwd_overriden_by_its_consumers_command_cwd() { let kdl_layout = r#" layout { diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap new file mode 100644 index 000000000..da83cc62c --- /dev/null +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_added_to_close_on_exit_in_template.snap @@ -0,0 +1,60 @@ +--- +source: zellij-utils/src/input/./unit/layout_test.rs +assertion_line: 1098 +expression: "format!(\"{:#?}\", layout)" +--- +Layout { + tabs: [], + focused_tab_index: None, + template: Some( + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: Some( + Command( + RunCommand { + command: "tail", + args: [], + cwd: None, + hold_on_close: true, + }, + ), + ), + borderless: false, + focus: None, + external_children_index: None, + }, + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: Some( + Command( + RunCommand { + command: "tail", + args: [], + cwd: None, + hold_on_close: false, + }, + ), + ), + borderless: false, + focus: None, + external_children_index: None, + }, + ], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + }, + ), +} diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap new file mode 100644 index 000000000..3cb80cf74 --- /dev/null +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__close_on_exit_overrides_close_on_exit_in_template.snap @@ -0,0 +1,60 @@ +--- +source: zellij-utils/src/input/./unit/layout_test.rs +assertion_line: 1064 +expression: "format!(\"{:#?}\", layout)" +--- +Layout { + tabs: [], + focused_tab_index: None, + template: Some( + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: Some( + Command( + RunCommand { + command: "tail", + args: [], + cwd: None, + hold_on_close: true, + }, + ), + ), + borderless: false, + focus: None, + external_children_index: None, + }, + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: Some( + Command( + RunCommand { + command: "tail", + args: [], + cwd: None, + hold_on_close: false, + }, + ), + ), + borderless: false, + focus: None, + external_children_index: None, + }, + ], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + }, + ), +} diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap new file mode 100644 index 000000000..69e3d7f1f --- /dev/null +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__layout_with_command_panes_and_close_on_exit.snap @@ -0,0 +1,41 @@ +--- +source: zellij-utils/src/input/./unit/layout_test.rs +assertion_line: 281 +expression: "format!(\"{:#?}\", layout)" +--- +Layout { + tabs: [], + focused_tab_index: None, + template: Some( + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + PaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: Some( + Command( + RunCommand { + command: "htop", + args: [], + cwd: None, + hold_on_close: false, + }, + ), + ), + borderless: false, + focus: None, + external_children_index: None, + }, + ], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + }, + ), +} |