test(command): update tests to use ExecuteCommand instead of QuitCmd
Update command tests to work with the new trait-based system: - Tests now use ExecuteCommand instead of QuitCmd - Added buffer setup with 'q' command for quit functionality - Tests verify effects contain SetStatus or ChangeMode via debug output - Removed direct QuitCmd construction in favor of ExecuteCommand The tests verify that quit behavior works correctly when dirty vs clean, ensuring the new command system produces the expected effects. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -2067,25 +2067,27 @@ mod tests {
|
||||
#[test]
|
||||
fn quit_when_dirty_shows_warning() {
|
||||
let m = two_cat_model();
|
||||
let mut bufs = HashMap::new();
|
||||
bufs.insert("command".to_string(), "q".to_string());
|
||||
let mut ctx = make_ctx(&m);
|
||||
ctx.dirty = true;
|
||||
let cmd = QuitCmd;
|
||||
ctx.buffers = &bufs;
|
||||
let cmd = ExecuteCommand;
|
||||
let effects = cmd.execute(&ctx);
|
||||
// Should produce a status message, not a mode change to Quit
|
||||
assert_eq!(effects.len(), 1);
|
||||
// Verify it's a SetStatus by checking debug output
|
||||
let dbg = format!("{:?}", effects[0]);
|
||||
let dbg = format!("{:?}", effects);
|
||||
assert!(dbg.contains("SetStatus"), "Expected SetStatus, got: {dbg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quit_when_clean_produces_quit_mode() {
|
||||
let m = two_cat_model();
|
||||
let ctx = make_ctx(&m);
|
||||
let cmd = QuitCmd;
|
||||
let mut bufs = HashMap::new();
|
||||
bufs.insert("command".to_string(), "q".to_string());
|
||||
let mut ctx = make_ctx(&m);
|
||||
ctx.buffers = &bufs;
|
||||
let cmd = ExecuteCommand;
|
||||
let effects = cmd.execute(&ctx);
|
||||
assert_eq!(effects.len(), 1);
|
||||
let dbg = format!("{:?}", effects[0]);
|
||||
let dbg = format!("{:?}", effects);
|
||||
assert!(
|
||||
dbg.contains("ChangeMode"),
|
||||
"Expected ChangeMode, got: {dbg}"
|
||||
|
||||
Reference in New Issue
Block a user