refactor(test): simplify assertions and calls in various tests

Clean up various test cases by simplifying Option checks, removing
redundant clones, using contains instead of any for DateComponent checks,
and removing unnecessary references in string formatting.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-31B-it-UD-Q4_K_XL.gguf)
This commit is contained in:
Edward Langley
2026-04-14 01:03:25 -07:00
parent f3996da2ec
commit d551d53eb4
3 changed files with 10 additions and 22 deletions

View File

@ -1003,20 +1003,12 @@ mod tests {
// Toggle Year component (cursor 0 = Year of first time field)
let had_year_before = {
let tc = w.time_category_proposals();
!tc.is_empty()
&& tc[0]
.date_components
.iter()
.any(|c| *c == DateComponent::Year)
!tc.is_empty() && tc[0].date_components.contains(&DateComponent::Year)
};
w.toggle_date_component();
let has_year_after = {
let tc = w.time_category_proposals();
!tc.is_empty()
&& tc[0]
.date_components
.iter()
.any(|c| *c == DateComponent::Year)
!tc.is_empty() && tc[0].date_components.contains(&DateComponent::Year)
};
assert_ne!(had_year_before, has_year_after);
}

View File

@ -1781,7 +1781,7 @@ mod five_category {
let m = build_model();
let count = DATA
.iter()
.filter(|&&(r, p, c, t, _, _)| !m.get_cell(&coord(r, p, c, t, "Revenue")).is_none())
.filter(|&&(r, p, c, t, _, _)| m.get_cell(&coord(r, p, c, t, "Revenue")).is_some())
.count();
assert_eq!(count, 16);
}
@ -1791,7 +1791,7 @@ mod five_category {
let m = build_model();
let count = DATA
.iter()
.filter(|&&(r, p, c, t, _, _)| !m.get_cell(&coord(r, p, c, t, "Cost")).is_none())
.filter(|&&(r, p, c, t, _, _)| m.get_cell(&coord(r, p, c, t, "Cost")).is_some())
.count();
assert_eq!(count, 16);
}
@ -1812,12 +1812,8 @@ mod five_category {
#[test]
fn distinct_cells_do_not_alias() {
let m = build_model();
let a = m
.get_cell(&coord("East", "Shirts", "Online", "Q1", "Revenue"))
.clone();
let b = m
.get_cell(&coord("West", "Pants", "Retail", "Q2", "Revenue"))
.clone();
let a = m.get_cell(&coord("East", "Shirts", "Online", "Q1", "Revenue"));
let b = m.get_cell(&coord("West", "Pants", "Retail", "Q2", "Revenue"));
assert_ne!(a, b);
}

View File

@ -601,7 +601,7 @@ mod tests {
app.model
.category_mut("Row")
.unwrap()
.add_item(&format!("R{i}"));
.add_item(format!("R{i}"));
}
app.term_height = 28; // ~20 visible rows → delta = 15
app.model.active_view_mut().selected = (0, 0);
@ -623,7 +623,7 @@ mod tests {
app.model
.category_mut("Row")
.unwrap()
.add_item(&format!("R{i}"));
.add_item(format!("R{i}"));
}
app.term_height = 28;
app.model.active_view_mut().selected = (20, 0);
@ -640,7 +640,7 @@ mod tests {
app.model
.category_mut("Row")
.unwrap()
.add_item(&format!("R{i}"));
.add_item(format!("R{i}"));
}
app.term_height = 13; // ~5 visible rows
app.model.active_view_mut().selected = (0, 0);
@ -665,7 +665,7 @@ mod tests {
app.model
.category_mut("Row")
.unwrap()
.add_item(&format!("R{i}"));
.add_item(format!("R{i}"));
}
app.term_height = 13; // ~5 visible rows
app.model.active_view_mut().selected = (0, 0);