diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index 13eb21d6..9ebd3ca6 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -1807,26 +1807,7 @@ fn close(s: &mut Session, p: &Value) -> Result { } #[cfg(test)] -mod tab_order_tests { - use super::*; - - #[test] - fn moving_and_closing_inactive_tabs_preserves_the_active_document() { - let mut session = Session::new(); - for name in ["Two", "Three", "Four"] { - session.execute("file.new", &json!({"name": name})).unwrap(); - } - session.execute("doc.switch", &json!({"index": 2})).unwrap(); - let active_uid = session.docs[session.active].uid; - let moved_uid = session.docs[0].uid; - session.execute("file.moveTab", &json!({"from": 0, "to": 2})).unwrap(); - assert_eq!(session.docs[2].uid, moved_uid); - assert_eq!(session.docs[session.active].uid, active_uid); - session.execute("file.close", &json!({"index": 0})).unwrap(); - assert_eq!(session.docs[session.active].uid, active_uid); - assert!(session.execute("file.moveTab", &json!({"from": 0, "to": 99})).is_err()); - } -} +mod tab_order_tests; /// Ctrl+Tab / Ctrl+Shift+Tab: the next or previous open document, wrapping around. fn cycle_doc(s: &mut Session, dir: i64) -> Result { diff --git a/crates/engine/src/cmd/file/tab_order_tests.rs b/crates/engine/src/cmd/file/tab_order_tests.rs new file mode 100644 index 00000000..f884ee42 --- /dev/null +++ b/crates/engine/src/cmd/file/tab_order_tests.rs @@ -0,0 +1,18 @@ +use super::*; + +#[test] +fn moving_and_closing_inactive_tabs_preserves_the_active_document() { + let mut session = Session::new(); + for name in ["Two", "Three", "Four"] { + session.execute("file.new", &json!({"name": name})).unwrap(); + } + session.execute("doc.switch", &json!({"index": 2})).unwrap(); + let active_uid = session.docs[session.active].uid; + let moved_uid = session.docs[0].uid; + session.execute("file.moveTab", &json!({"from": 0, "to": 2})).unwrap(); + assert_eq!(session.docs[2].uid, moved_uid); + assert_eq!(session.docs[session.active].uid, active_uid); + session.execute("file.close", &json!({"index": 0})).unwrap(); + assert_eq!(session.docs[session.active].uid, active_uid); + assert!(session.execute("file.moveTab", &json!({"from": 0, "to": 99})).is_err()); +}