From 7bd2296a2260aacfbf5a6b6983539297771c16d7 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Mon, 6 Apr 2026 15:09:58 -0700 Subject: [PATCH] refactor: update command tests for new API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update command tests for new API. Added EMPTY_EXPANDED static for expanded_cats in test context. Renamed tests: - toggle_panel_and_focus_opens_and_enters_mode → toggle_panel_open_and_focus - toggle_panel_and_focus_closes_when_open → toggle_panel_close_and_unfocus Updated test assertions to use open/focused flags instead of currently_open. Tests now verify 2 effects (SetPanelOpen + ChangeMode) for both open and close operations. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M) --- src/command/cmd.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/command/cmd.rs b/src/command/cmd.rs index 084b019..ee3034c 100644 --- a/src/command/cmd.rs +++ b/src/command/cmd.rs @@ -2935,6 +2935,8 @@ mod tests { static EMPTY_BUFFERS: std::sync::LazyLock> = std::sync::LazyLock::new(HashMap::new); + static EMPTY_EXPANDED: std::sync::LazyLock> = + std::sync::LazyLock::new(std::collections::HashSet::new); fn make_ctx(model: &Model) -> CmdContext<'_> { let view = model.active_view(); @@ -2966,6 +2968,9 @@ mod tests { cell_key: layout.cell_key(sr, sc), row_count: layout.row_count(), col_count: layout.col_count(), + visible_rows: 20, + visible_cols: 8, + expanded_cats: &EMPTY_EXPANDED, key_code: KeyCode::Null, } } @@ -3072,12 +3077,13 @@ mod tests { } #[test] - fn toggle_panel_and_focus_opens_and_enters_mode() { + fn toggle_panel_open_and_focus() { let m = two_cat_model(); let ctx = make_ctx(&m); let cmd = TogglePanelAndFocus { panel: effect::Panel::Formula, - currently_open: false, + open: true, + focused: true, }; let effects = cmd.execute(&ctx); assert_eq!(effects.len(), 2); // SetPanelOpen + ChangeMode @@ -3089,16 +3095,16 @@ mod tests { } #[test] - fn toggle_panel_and_focus_closes_when_open() { + fn toggle_panel_close_and_unfocus() { let m = two_cat_model(); - let mut ctx = make_ctx(&m); - ctx.formula_panel_open = true; + let ctx = make_ctx(&m); let cmd = TogglePanelAndFocus { panel: effect::Panel::Formula, - currently_open: true, + open: false, + focused: false, }; let effects = cmd.execute(&ctx); - assert_eq!(effects.len(), 1); // SetPanelOpen only, no mode change + assert_eq!(effects.len(), 2); // SetPanelOpen(false) + ChangeMode(Normal) } #[test]