107 lines
3.4 KiB
Rust
107 lines
3.4 KiB
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn test_has_horizontal_split() {
|
|
let single_leaf = PaneNodeSnapshot::Leaf(LeafSnapshot {
|
|
is_focused: false,
|
|
custom_vertical_tabs_title: None,
|
|
contents: LeafContents::Code(CodePaneSnapShot::Local {
|
|
tabs: vec![CodePaneTabSnapshot {
|
|
path: Some(PathBuf::new()),
|
|
}],
|
|
active_tab_index: 0,
|
|
source: None,
|
|
}),
|
|
});
|
|
assert!(!single_leaf.has_horizontal_split());
|
|
|
|
let horizontal_split = PaneNodeSnapshot::Branch(BranchSnapshot {
|
|
direction: SplitDirection::Horizontal,
|
|
children: vec![
|
|
(
|
|
PaneFlex(1.),
|
|
PaneNodeSnapshot::Leaf(LeafSnapshot {
|
|
is_focused: false,
|
|
custom_vertical_tabs_title: None,
|
|
contents: LeafContents::Code(CodePaneSnapShot::Local {
|
|
tabs: vec![CodePaneTabSnapshot {
|
|
path: Some(PathBuf::new()),
|
|
}],
|
|
active_tab_index: 0,
|
|
source: None,
|
|
}),
|
|
}),
|
|
),
|
|
(
|
|
PaneFlex(1.),
|
|
PaneNodeSnapshot::Leaf(LeafSnapshot {
|
|
is_focused: false,
|
|
custom_vertical_tabs_title: None,
|
|
contents: LeafContents::Code(CodePaneSnapShot::Local {
|
|
tabs: vec![CodePaneTabSnapshot {
|
|
path: Some(PathBuf::new()),
|
|
}],
|
|
active_tab_index: 0,
|
|
source: None,
|
|
}),
|
|
}),
|
|
),
|
|
],
|
|
});
|
|
assert!(horizontal_split.has_horizontal_split());
|
|
}
|
|
|
|
#[test]
|
|
fn test_code_pane_snapshot_single_tab() {
|
|
let snapshot = CodePaneSnapShot::Local {
|
|
tabs: vec![CodePaneTabSnapshot {
|
|
path: Some(PathBuf::from("/tmp/test.rs")),
|
|
}],
|
|
active_tab_index: 0,
|
|
source: Some(CodeSource::FileTree {
|
|
path: PathBuf::from("/tmp/test.rs"),
|
|
}),
|
|
};
|
|
let CodePaneSnapShot::Local {
|
|
tabs,
|
|
active_tab_index,
|
|
source,
|
|
} = &snapshot;
|
|
assert_eq!(tabs.len(), 1);
|
|
assert_eq!(*active_tab_index, 0);
|
|
assert_eq!(tabs[0].path, Some(PathBuf::from("/tmp/test.rs")));
|
|
assert!(matches!(source, Some(CodeSource::FileTree { .. })));
|
|
}
|
|
|
|
#[test]
|
|
fn test_code_pane_snapshot_with_multiple_tabs() {
|
|
let snapshot = CodePaneSnapShot::Local {
|
|
tabs: vec![
|
|
CodePaneTabSnapshot {
|
|
path: Some(PathBuf::from("/tmp/main.rs")),
|
|
},
|
|
CodePaneTabSnapshot {
|
|
path: Some(PathBuf::from("/tmp/lib.rs")),
|
|
},
|
|
CodePaneTabSnapshot { path: None },
|
|
],
|
|
active_tab_index: 1,
|
|
source: Some(CodeSource::Link {
|
|
path: PathBuf::from("/tmp/main.rs"),
|
|
range_start: None,
|
|
range_end: None,
|
|
}),
|
|
};
|
|
let CodePaneSnapShot::Local {
|
|
tabs,
|
|
active_tab_index,
|
|
source,
|
|
} = &snapshot;
|
|
assert_eq!(tabs.len(), 3);
|
|
assert_eq!(*active_tab_index, 1);
|
|
assert_eq!(tabs[0].path, Some(PathBuf::from("/tmp/main.rs")));
|
|
assert_eq!(tabs[1].path, Some(PathBuf::from("/tmp/lib.rs")));
|
|
assert_eq!(tabs[2].path, None);
|
|
assert!(matches!(source, Some(CodeSource::Link { .. })));
|
|
}
|