From aae9338f664a65aee6feff18cc72d84a398e8092 Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Tue, 3 Jun 2025 16:46:39 -0500 Subject: [PATCH] test(wm): toggle maximize a nonexistent window The test ensures that we receive an error when attempting to toggle maximize a window that doesn't exist. --- komorebi/src/window_manager.rs | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 2b702d78..b2ad00ca 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5728,6 +5728,41 @@ mod tests { } } + #[test] + fn test_toggle_maximize_nonexistent_window() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDevice".to_string(), + "TestDeviceID".to_string(), + Some("TestMonitorID".to_string()), + ); + + // Create a container + let container = Container::default(); + + // Add the container to the workspace + let workspace = m.focused_workspace_mut().unwrap(); + workspace.add_container_to_back(container); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to toggle maximize on a non-existent window + let result = wm.toggle_maximize(); + assert!( + result.is_err(), + "Expected an error when trying to toggle maximize on a non-existent window" + ); + } + #[test] fn test_monocle_on_and_monocle_off() { let (mut wm, _context) = setup_window_manager();