refactor: update command tests for new API

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)
This commit is contained in:
Edward Langley
2026-04-06 15:09:58 -07:00
parent 21f3e2c58e
commit 7bd2296a22

View File

@ -2935,6 +2935,8 @@ mod tests {
static EMPTY_BUFFERS: std::sync::LazyLock<HashMap<String, String>> = static EMPTY_BUFFERS: std::sync::LazyLock<HashMap<String, String>> =
std::sync::LazyLock::new(HashMap::new); std::sync::LazyLock::new(HashMap::new);
static EMPTY_EXPANDED: std::sync::LazyLock<std::collections::HashSet<String>> =
std::sync::LazyLock::new(std::collections::HashSet::new);
fn make_ctx(model: &Model) -> CmdContext<'_> { fn make_ctx(model: &Model) -> CmdContext<'_> {
let view = model.active_view(); let view = model.active_view();
@ -2966,6 +2968,9 @@ mod tests {
cell_key: layout.cell_key(sr, sc), cell_key: layout.cell_key(sr, sc),
row_count: layout.row_count(), row_count: layout.row_count(),
col_count: layout.col_count(), col_count: layout.col_count(),
visible_rows: 20,
visible_cols: 8,
expanded_cats: &EMPTY_EXPANDED,
key_code: KeyCode::Null, key_code: KeyCode::Null,
} }
} }
@ -3072,12 +3077,13 @@ mod tests {
} }
#[test] #[test]
fn toggle_panel_and_focus_opens_and_enters_mode() { fn toggle_panel_open_and_focus() {
let m = two_cat_model(); let m = two_cat_model();
let ctx = make_ctx(&m); let ctx = make_ctx(&m);
let cmd = TogglePanelAndFocus { let cmd = TogglePanelAndFocus {
panel: effect::Panel::Formula, panel: effect::Panel::Formula,
currently_open: false, open: true,
focused: true,
}; };
let effects = cmd.execute(&ctx); let effects = cmd.execute(&ctx);
assert_eq!(effects.len(), 2); // SetPanelOpen + ChangeMode assert_eq!(effects.len(), 2); // SetPanelOpen + ChangeMode
@ -3089,16 +3095,16 @@ mod tests {
} }
#[test] #[test]
fn toggle_panel_and_focus_closes_when_open() { fn toggle_panel_close_and_unfocus() {
let m = two_cat_model(); let m = two_cat_model();
let mut ctx = make_ctx(&m); let ctx = make_ctx(&m);
ctx.formula_panel_open = true;
let cmd = TogglePanelAndFocus { let cmd = TogglePanelAndFocus {
panel: effect::Panel::Formula, panel: effect::Panel::Formula,
currently_open: true, open: false,
focused: false,
}; };
let effects = cmd.execute(&ctx); 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] #[test]