mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-17 23:13:55 +01:00
test(workspace): remove a non existent window
Created a test for removing a window that doesn't exist. The test creates a container with a window and then attempts to remove a window that doesn't exist. The test will check the result to ensure that the result returned an error and that we still have the expected number of windows.
This commit is contained in:
@@ -1939,6 +1939,33 @@ mod tests {
|
||||
assert_eq!(container.windows().len(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_non_existent_window() {
|
||||
let mut workspace = Workspace::default();
|
||||
|
||||
{
|
||||
// Add a container with one window
|
||||
let mut container = Container::default();
|
||||
container.windows_mut().push_back(Window::from(1));
|
||||
workspace.add_container_to_back(container);
|
||||
}
|
||||
|
||||
// Attempt to remove a non-existent window
|
||||
let result = workspace.remove_window(2);
|
||||
|
||||
// Should return an error
|
||||
assert!(
|
||||
result.is_err(),
|
||||
"Expected an error when removing a non-existent window"
|
||||
);
|
||||
|
||||
// Get focused container. Should be the index of the last container added
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
|
||||
// Should still have 1 window
|
||||
assert_eq!(container.windows().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_focused_container() {
|
||||
let mut workspace = Workspace::default();
|
||||
|
||||
Reference in New Issue
Block a user