test: add tests for diff toggle and update changelog

This commit is contained in:
Kamil Cukrowski 2026-05-10 00:04:04 +02:00
parent 83df0a80e7
commit 5cf6719003
2 changed files with 33 additions and 0 deletions

View file

@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* use [tombi](https://github.com/tombi-toml/tombi) for all toml file formatting
* open the external editor from the status diff view [[@WaterWhisperer](https://github.com/WaterWhisperer)] ([#2805](https://github.com/gitui-org/gitui/issues/2805))
* change diff mode toggle shortcut from `Alt+p` to `m`
### Fixes
* crash when opening submodule ([#2895](https://github.com/gitui-org/gitui/issues/2895))
* when staging the last file in a directory, the first item after the directory is no longer skipped [[@Tillerino](https://github.com/Tillerino)] ([#2748](https://github.com/gitui-org/gitui/issues/2748))
* fixed duplicated "Toggle Diff Mode" in help message
## [0.28.1] - 2026-03-21

View file

@ -1710,4 +1710,35 @@ mod tests {
if path == "src/main.rs"
));
}
#[test]
fn test_commands_no_longer_contains_toggle_diff() {
let env = Environment::test_env();
let diff = DiffComponent::new(&env, false);
let mut cmds = Vec::new();
diff.commands(&mut cmds, true);
let contains_toggle = cmds.iter().any(|c| {
c.text.name
== strings::commands::diff_toggle_mode(&env.key_config)
.name
});
assert!(!contains_toggle);
}
#[test]
fn test_diff_mode_toggle_event() {
let env = Environment::test_env();
let mut diff = DiffComponent::new(&env, false);
diff.focus(true);
let event = Event::Key(KeyEvent::from(
&env.key_config.keys.diff_mode_toggle,
));
assert!(matches!(
diff.event(&event).unwrap(),
EventState::Consumed
));
}
}