aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input/unit
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-08-21 23:27:23 +0200
committera-kenji <aks.kenji@protonmail.com>2021-08-21 23:27:23 +0200
commit88b4063879845cf53397f60201473ce386280cfe (patch)
tree2451496e64350111d503673bcdac11a4f2b5d6a6 /zellij-utils/src/input/unit
parentChange layout panics to errors (diff)
downloadsl0ppij-88b4063879845cf53397f60201473ce386280cfe.tar.gz
sl0ppij-88b4063879845cf53397f60201473ce386280cfe.tar.xz
sl0ppij-88b4063879845cf53397f60201473ce386280cfe.zip
Add `template` section in `layout` file
It works as follows: ``` --- template: direction: Horizontal parts: - direction: Vertical split_size: Fixed: 1 run: plugin: tab-bar - direction: Vertical body: true - direction: Vertical split_size: Fixed: 2 run: plugin: status-bar tabs: - direction: Vertical ``` The tabs are created in the body section of the template.
Diffstat (limited to 'zellij-utils/src/input/unit')
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/deeply-nested-tab-layout.yaml79
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/no-tabs-should-error.yaml18
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/tabs-and-parts-together-should-error.yaml17
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-command.yaml57
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-default-plugins.yaml49
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab.yaml31
-rw-r--r--zellij-utils/src/input/unit/fixtures/layouts/three-tabs-merged-correctly.yaml36
-rw-r--r--zellij-utils/src/input/unit/layout_test.rs225
8 files changed, 244 insertions, 268 deletions
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/deeply-nested-tab-layout.yaml b/zellij-utils/src/input/unit/fixtures/layouts/deeply-nested-tab-layout.yaml
index 11e5323e..633a1fae 100644
--- a/zellij-utils/src/input/unit/fixtures/layouts/deeply-nested-tab-layout.yaml
+++ b/zellij-utils/src/input/unit/fixtures/layouts/deeply-nested-tab-layout.yaml
@@ -1,40 +1,43 @@
---
-direction: Horizontal
-parts:
- - direction: Vertical
- parts:
- - direction: Horizontal
- split_size:
- Percent: 21
- - direction: Vertical
- split_size:
- Percent: 79
- parts:
- - direction: Horizontal
- split_size:
- Percent: 22
- - direction: Horizontal
- split_size:
- Percent: 78
- parts:
- - direction: Horizontal
- split_size:
- Percent: 23
- - direction: Vertical
- split_size:
- Percent: 77
- tabs:
- - direction: Horizontal
- split_size:
- Percent: 24
+template:
+ direction: Horizontal
+ parts:
+ - direction: Vertical
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 21
+ - direction: Vertical
+ split_size:
+ Percent: 79
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 22
+ - direction: Horizontal
+ split_size:
+ Percent: 78
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 23
+ - direction: Vertical
+ split_size:
+ Percent: 77
+ body: true
+ split_size:
+ Percent: 90
+ - direction: Vertical
+ split_size:
+ Percent: 15
+ - direction: Vertical
+ split_size:
+ Percent: 15
+ - direction: Vertical
+ split_size:
+ Percent: 15
+
+tabs:
+ - direction: Horizontal
split_size:
- Percent: 90
- - direction: Vertical
- split_size:
- Percent: 15
- - direction: Vertical
- split_size:
- Percent: 15
- - direction: Vertical
- split_size:
- Percent: 15
+ Percent: 24
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/no-tabs-should-error.yaml b/zellij-utils/src/input/unit/fixtures/layouts/no-tabs-should-error.yaml
deleted file mode 100644
index a67b0ff9..00000000
--- a/zellij-utils/src/input/unit/fixtures/layouts/no-tabs-should-error.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
----
-direction: Horizontal
-parts:
- - direction: Horizontal
- parts:
- - direction: Vertical
- parts:
- - direction: Horizontal
- split_size:
- Percent: 50
- - direction: Horizontal
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Vertical
- split_size:
- Percent: 50
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/tabs-and-parts-together-should-error.yaml b/zellij-utils/src/input/unit/fixtures/layouts/tabs-and-parts-together-should-error.yaml
deleted file mode 100644
index e7223602..00000000
--- a/zellij-utils/src/input/unit/fixtures/layouts/tabs-and-parts-together-should-error.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
----
-direction: Horizontal
-parts:
- - direction: Horizontal
- tabs:
- - direction: Vertical
- parts:
- - direction: Horizontal
- split_size:
- Percent: 50
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Vertical
- split_size:
- Percent: 50
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-command.yaml b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-command.yaml
index 34de4291..9ad1034d 100644
--- a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-command.yaml
+++ b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-command.yaml
@@ -1,32 +1,35 @@
---
-direction: Horizontal
-parts:
+template:
+ direction: Horizontal
+ parts:
+ - direction: Vertical
+ split_size:
+ Fixed: 1
+ run:
+ plugin: tab-bar
+ - direction: Horizontal
+ body: true
+ - direction: Vertical
+ split_size:
+ Fixed: 2
+ run:
+ plugin: status-bar
+
+tabs:
- direction: Vertical
- split_size:
- Fixed: 1
- run:
- plugin: tab-bar
- - direction: Horizontal
- tabs:
- - direction: Vertical
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 50
+ - direction: Horizontal
parts:
- - direction: Horizontal
+ - direction: Vertical
split_size:
Percent: 50
- - direction: Horizontal
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- run:
- command: {cmd: htop}
- - direction: Vertical
- split_size:
- Percent: 50
- run:
- command: {cmd: htop, args: ["-C"]}
- - direction: Vertical
- split_size:
- Fixed: 2
- run:
- plugin: status-bar
+ run:
+ command: {cmd: htop}
+ - direction: Vertical
+ split_size:
+ Percent: 50
+ run:
+ command: {cmd: htop, args: ["-C"]}
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-default-plugins.yaml b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-default-plugins.yaml
index a803f291..88046395 100644
--- a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-default-plugins.yaml
+++ b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab-and-default-plugins.yaml
@@ -1,28 +1,31 @@
---
-direction: Horizontal
-parts:
+template:
+ direction: Horizontal
+ parts:
+ - direction: Vertical
+ split_size:
+ Fixed: 1
+ run:
+ plugin: tab-bar
+ - direction: Horizontal
+ body: true
+ - direction: Vertical
+ split_size:
+ Fixed: 2
+ run:
+ plugin: status-bar
+
+tabs:
- direction: Vertical
- split_size:
- Fixed: 1
- run:
- plugin: tab-bar
- - direction: Horizontal
- tabs:
- - direction: Vertical
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 50
+ - direction: Horizontal
parts:
- - direction: Horizontal
+ - direction: Vertical
+ split_size:
+ Percent: 50
+ - direction: Vertical
split_size:
Percent: 50
- - direction: Horizontal
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Vertical
- split_size:
- Fixed: 2
- run:
- plugin: status-bar
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab.yaml b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab.yaml
index e0f25b92..83f05076 100644
--- a/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab.yaml
+++ b/zellij-utils/src/input/unit/fixtures/layouts/three-panes-with-tab.yaml
@@ -1,18 +1,21 @@
---
-direction: Horizontal
-parts:
- - direction: Horizontal
- tabs:
- - direction: Vertical
+template:
+ direction: Horizontal
+ parts:
+ - direction: Horizontal
+ body: true
+
+tabs:
+ - direction: Vertical
+ parts:
+ - direction: Horizontal
+ split_size:
+ Percent: 50
+ - direction: Horizontal
parts:
- - direction: Horizontal
+ - direction: Vertical
+ split_size:
+ Percent: 50
+ - direction: Vertical
split_size:
Percent: 50
- - direction: Horizontal
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Vertical
- split_size:
- Percent: 50
diff --git a/zellij-utils/src/input/unit/fixtures/layouts/three-tabs-merged-correctly.yaml b/zellij-utils/src/input/unit/fixtures/layouts/three-tabs-merged-correctly.yaml
index 96e1524d..e2a09a73 100644
--- a/zellij-utils/src/input/unit/fixtures/layouts/three-tabs-merged-correctly.yaml
+++ b/zellij-utils/src/input/unit/fixtures/layouts/three-tabs-merged-correctly.yaml
@@ -1,25 +1,29 @@
---
-direction: Vertical
-parts:
+template:
+ direction: Vertical
+ parts:
+ - direction: Horizontal
+ body: true
+ - direction: Horizontal
+
+
+tabs:
- direction: Horizontal
- tabs:
+ split_size:
+ Percent: 50
+ - direction: Horizontal
+ split_size:
+ Percent: 50
+ parts:
- direction: Horizontal
split_size:
Percent: 50
- direction: Horizontal
- split_size:
- Percent: 50
- parts:
- - direction: Horizontal
- split_size:
- Percent: 50
- - direction: Horizontal
+ - direction: Vertical
+ split_size:
+ Percent: 50
+ parts:
- direction: Vertical
split_size:
Percent: 50
- parts:
- - direction: Vertical
- split_size:
- Percent: 50
- - direction: Horizontal
- - direction: Horizontal
+ - direction: Horizontal
diff --git a/zellij-utils/src/input/unit/layout_test.rs b/zellij-utils/src/input/unit/layout_test.rs
index 1a90c1ff..d09d328c 100644
--- a/zellij-utils/src/input/unit/layout_test.rs
+++ b/zellij-utils/src/input/unit/layout_test.rs
@@ -15,40 +15,43 @@ fn default_layout_dir(layout: String) -> PathBuf {
#[test]
fn default_layout_is_ok() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
+ let layout = LayoutFromYaml::new(&path);
assert!(layout.is_ok());
}
#[test]
fn default_layout_has_one_tab() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 1);
}
#[test]
fn default_layout_has_one_pre_tab() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.pre_tab.parts.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ assert_eq!(layout_template.pre_tab.parts.len(), 1);
}
#[test]
fn default_layout_has_one_post_tab() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.post_tab.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ assert_eq!(layout_template.post_tab.len(), 1);
}
#[test]
fn default_layout_merged_correctly() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[0].clone()));
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[0].clone()));
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![
@@ -84,9 +87,12 @@ fn default_layout_merged_correctly() {
#[test]
fn default_layout_new_tab_correct() {
let path = default_layout_dir("default.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(None);
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(None);
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![
@@ -122,78 +128,84 @@ fn default_layout_new_tab_correct() {
#[test]
fn default_strider_layout_is_ok() {
let path = default_layout_dir("strider.yaml".into());
- let layout = Layout::new(&path);
- assert!(layout.is_ok());
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ assert!(layout_from_yaml.is_ok());
}
#[test]
fn default_disable_status_layout_is_ok() {
let path = default_layout_dir("disable-status-bar.yaml".into());
- let layout = Layout::new(&path);
- assert!(layout.is_ok());
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ assert!(layout_from_yaml.is_ok());
}
#[test]
-fn default_disable_status_layout_has_one_tab() {
+fn default_disable_status_layout_has_no_tab() {
let path = default_layout_dir("disable-status-bar.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 1);
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 0);
}
#[test]
fn default_disable_status_layout_has_one_pre_tab() {
let path = default_layout_dir("disable-status-bar.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.pre_tab.parts.len(), 1);
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ assert_eq!(layout_template.pre_tab.parts.len(), 1);
}
#[test]
fn default_disable_status_layout_has_no_post_tab() {
let path = default_layout_dir("disable-status-bar.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- assert!(main_layout.post_tab.is_empty());
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ assert!(layout_template.post_tab.is_empty());
}
#[test]
fn three_panes_with_tab_is_ok() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
+ let layout = LayoutFromYaml::new(&path);
assert!(layout.is_ok());
}
#[test]
fn three_panes_with_tab_has_one_tab() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 1);
}
#[test]
fn three_panes_with_tab_no_post_tab() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert!(main_layout.post_tab.is_empty());
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert!(layout_template.post_tab.is_empty());
}
#[test]
fn three_panes_with_tab_no_pre_tab() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert!(main_layout.pre_tab.parts.is_empty());
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert!(layout_template.pre_tab.parts.is_empty());
}
#[test]
fn three_panes_with_tab_merged_correctly() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[0].clone()));
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[0].clone()));
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![Layout {
@@ -243,9 +255,9 @@ fn three_panes_with_tab_merged_correctly() {
#[test]
fn three_panes_with_tab_new_tab_is_correct() {
let path = layout_test_dir("three-panes-with-tab.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(None);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(None);
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![Layout {
@@ -265,40 +277,40 @@ fn three_panes_with_tab_new_tab_is_correct() {
#[test]
fn three_panes_with_tab_and_default_plugins_is_ok() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
+ let layout = LayoutFromYaml::new(&path);
assert!(layout.is_ok());
}
#[test]
fn three_panes_with_tab_and_default_plugins_has_one_tab() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 1);
}
#[test]
fn three_panes_with_tab_and_default_plugins_one_post_tab() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.post_tab.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert_eq!(layout_template.post_tab.len(), 1);
}
#[test]
fn three_panes_with_tab_and_default_plugins_has_pre_tab() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert!(!main_layout.pre_tab.parts.is_empty());
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert!(!layout_template.pre_tab.parts.is_empty());
}
#[test]
fn three_panes_with_tab_and_default_plugins_merged_correctly() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[0].clone()));
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[0].clone()));
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![
@@ -364,9 +376,9 @@ fn three_panes_with_tab_and_default_plugins_merged_correctly() {
#[test]
fn three_panes_with_tab_and_default_plugins_new_tab_is_correct() {
let path = layout_test_dir("three-panes-with-tab-and-default-plugins.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(None);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(None);
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![
@@ -402,40 +414,40 @@ fn three_panes_with_tab_and_default_plugins_new_tab_is_correct() {
#[test]
fn deeply_nested_tab_is_ok() {
let path = layout_test_dir("deeply-nested-tab-layout.yaml".into());
- let layout = Layout::new(&path);
+ let layout = LayoutFromYaml::new(&path);
assert!(layout.is_ok());
}
#[test]
fn deeply_nested_tab_has_one_tab() {
let path = layout_test_dir("deeply-nested-tab-layout.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 1);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 1);
}
#[test]
fn deeply_nested_tab_three_post_tab() {
let path = layout_test_dir("deeply-nested-tab-layout.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.post_tab.len(), 3);
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert_eq!(layout_template.post_tab.len(), 3);
}
#[test]
fn deeply_nested_tab_has_many_pre_tab() {
let path = layout_test_dir("deeply-nested-tab-layout.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert!(!main_layout.pre_tab.parts.is_empty());
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.unwrap().construct_layout_template();
+ assert!(!layout_template.pre_tab.parts.is_empty());
}
#[test]
fn deeply_nested_tab_merged_correctly() {
let path = layout_test_dir("deeply-nested-tab-layout.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[0].clone()));
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[0].clone()));
let merged_layout = Layout {
direction: Direction::Horizontal,
parts: vec![
@@ -519,57 +531,37 @@ fn deeply_nested_tab_merged_correctly() {
}
#[test]
-fn no_tabs_specified_should_err() {
- let path = layout_test_dir("no-tabs-should-error.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout();
- assert!(main_layout.is_err());
-}
-
-#[test]
-fn tabs_and_parts_specified_together_should_should_err() {
- let path = layout_test_dir("tabs-and-parts-together-should-error.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout();
- assert!(main_layout.is_err());
-}
-
-#[test]
-fn multiple_tabs_specified_should_not_err() {
- let path = layout_test_dir("multiple-tabs-should-not-error.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout();
- assert!(main_layout.is_ok())
-}
-#[test]
fn three_tabs_is_ok() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- assert!(layout.is_ok());
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ assert!(layout_from_yaml.is_ok());
}
#[test]
fn three_tabs_has_three_tabs() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.tabs.len(), 3);
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml.unwrap().construct_layout_template();
+ assert_eq!(layout_template.tabs.len(), 3);
}
#[test]
fn three_tabs_has_one_post_tab() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.unwrap().construct_main_layout().unwrap();
- assert_eq!(main_layout.post_tab.len(), 1);
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml.unwrap().construct_layout_template();
+ assert_eq!(layout_template.post_tab.len(), 1);
}
#[test]
fn three_tabs_tab_one_merged_correctly() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[0].clone()));
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[0].clone()));
let merged_layout = Layout {
direction: Direction::Vertical,
parts: vec![
@@ -599,9 +591,12 @@ fn three_tabs_tab_one_merged_correctly() {
#[test]
fn three_tabs_tab_two_merged_correctly() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[1].clone()));
+ let layout_from_yaml = LayoutFromYaml::new(&path);
+ let layout_template = layout_from_yaml
+ .as_ref()
+ .unwrap()
+ .construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[1].clone()));
let merged_layout = Layout {
direction: Direction::Vertical,
parts: vec![
@@ -646,9 +641,9 @@ fn three_tabs_tab_two_merged_correctly() {
#[test]
fn three_tabs_tab_three_merged_correctly() {
let path = layout_test_dir("three-tabs-merged-correctly.yaml".into());
- let layout = Layout::new(&path);
- let main_layout = layout.as_ref().unwrap().construct_main_layout().unwrap();
- let tab_layout = main_layout.construct_tab_layout(Some(main_layout.tabs[2].clone()));
+ let layout = LayoutFromYaml::new(&path);
+ let layout_template = layout.as_ref().unwrap().construct_layout_template();
+ let tab_layout = layout_template.construct_tab_layout(Some(layout_template.tabs[2].clone()));
let merged_layout = Layout {
direction: Direction::Vertical,
parts: vec![