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]
|
#[test]
|
||||||
fn quit_when_dirty_shows_warning() {
|
fn quit_when_dirty_shows_warning() {
|
||||||
let m = two_cat_model();
|
let m = two_cat_model();
|
||||||
|
let mut bufs = HashMap::new();
|
||||||
|
bufs.insert("command".to_string(), "q".to_string());
|
||||||
let mut ctx = make_ctx(&m);
|
let mut ctx = make_ctx(&m);
|
||||||
ctx.dirty = true;
|
ctx.dirty = true;
|
||||||
let cmd = QuitCmd;
|
ctx.buffers = &bufs;
|
||||||
|
let cmd = ExecuteCommand;
|
||||||
let effects = cmd.execute(&ctx);
|
let effects = cmd.execute(&ctx);
|
||||||
// Should produce a status message, not a mode change to Quit
|
let dbg = format!("{:?}", effects);
|
||||||
assert_eq!(effects.len(), 1);
|
|
||||||
// Verify it's a SetStatus by checking debug output
|
|
||||||
let dbg = format!("{:?}", effects[0]);
|
|
||||||
assert!(dbg.contains("SetStatus"), "Expected SetStatus, got: {dbg}");
|
assert!(dbg.contains("SetStatus"), "Expected SetStatus, got: {dbg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn quit_when_clean_produces_quit_mode() {
|
fn quit_when_clean_produces_quit_mode() {
|
||||||
let m = two_cat_model();
|
let m = two_cat_model();
|
||||||
let ctx = make_ctx(&m);
|
let mut bufs = HashMap::new();
|
||||||
let cmd = QuitCmd;
|
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);
|
let effects = cmd.execute(&ctx);
|
||||||
assert_eq!(effects.len(), 1);
|
let dbg = format!("{:?}", effects);
|
||||||
let dbg = format!("{:?}", effects[0]);
|
|
||||||
assert!(
|
assert!(
|
||||||
dbg.contains("ChangeMode"),
|
dbg.contains("ChangeMode"),
|
||||||
"Expected ChangeMode, got: {dbg}"
|
"Expected ChangeMode, got: {dbg}"
|
||||||
|
|||||||
Reference in New Issue
Block a user