From 7e87e831898082b2952985ad5bc357bd4c56b6db Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Tue, 3 Jun 2025 17:10:46 -0500 Subject: [PATCH] test(wm): toggle monocle on nonexistent container Created a test to test toggle monocle when a container doesn't exist in the monitor. The test ensures that we receive an error when attempting to call toggle monocle when a monitor doesn't contain a container. --- komorebi/src/window_manager.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index b2ad00ca..028f65ac 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5905,6 +5905,34 @@ mod tests { } } + #[test] + fn test_toggle_monocle_nonexistent_container() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a monitor + let m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDevice".to_string(), + "TestDeviceID".to_string(), + Some("TestMonitorID".to_string()), + ); + + // Add monitor to the window manager + wm.monitors_mut().push_back(m); + } + + // Should return an error when trying to toggle monocle on a non-existent container + let result = wm.toggle_monocle(); + assert!( + result.is_err(), + "Expected an error when trying to toggle monocle on a non-existent container" + ); + } + #[test] fn test_ensure_named_workspace_for_monitor() { let (mut wm, _context) = setup_window_manager();