diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index e0755d50..12228248 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -4880,6 +4880,44 @@ mod tests { } } + #[test] + fn test_cycle_nonexistent_windows() { + let (mut wm, _context) = setup_window_manager(); + + { + // Create a first monitor + let mut m = monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor1".to_string(), + "TestDevice1".to_string(), + "TestDeviceID1".to_string(), + Some("TestMonitorID1".to_string()), + ); + + // Create a container + let container = Container::default(); + + // Should have 3 windows in the container + assert_eq!(container.windows().len(), 0); + + // Add the container to a 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 cycle through windows in an empty container + let result = wm.cycle_container_window_in_direction(CycleDirection::Next); + assert!( + result.is_err(), + "Expected an error when cycling through windows in an empty container" + ); + } + #[test] fn test_cycle_container_window_index_in_direction() { let (mut wm, _context) = setup_window_manager();