From c879aae1e7f1a8170fb5d8d46663f1ea284db776 Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Tue, 3 Jun 2025 17:25:30 -0500 Subject: [PATCH] test(wm): monocle on and off on nonexistent container Created a test that tests moving a nonexistent container to monocle and retreiving a nonexistent container from monocle. The test ensures we receive an error when attempting to use monocle_on or monocle_off when a container 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 028f65ac..751ef4a0 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5834,6 +5834,41 @@ mod tests { } } + #[test] + fn test_monocle_on_and_off_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 move a non-existent container to monocle + let result = wm.monocle_on(); + assert!( + result.is_err(), + "Expected an error when trying to move a non-existent container to monocle" + ); + + // Should return an error when trying to restore a non-existent container from monocle + let result = wm.monocle_off(); + assert!( + result.is_err(), + "Expected an error when trying to restore a non-existent container from monocle" + ); + } + #[test] fn test_toggle_monocle() { let (mut wm, _context) = setup_window_manager();