Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/commands/list/ci_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,9 @@ mod tests {
// Call format_indicator(true) directly
let formatted = pr_with_url.format_indicator(true);
// Should contain OSC 8 hyperlink escape sequences
assert!(formatted.contains("\x1b]8;;"), "Should contain OSC 8 start");
assert!(
formatted.contains("https://github.com/owner/repo/pull/123"),
"Should contain URL"
);
assert!(formatted.contains("●"), "Should contain indicator");
assert!(formatted.contains("\x1b]8;;"));
assert!(formatted.contains("https://github.com/owner/repo/pull/123"));
assert!(formatted.contains("●"));
}

#[test]
Expand All @@ -266,7 +263,7 @@ mod tests {
!formatted.contains("\x1b]8;;"),
"Should not contain OSC 8 sequences"
);
assert!(formatted.contains("●"), "Should contain indicator");
assert!(formatted.contains("●"));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/commands/list/progressive_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mod tests {
assert_eq!(table.lines[0], header);
assert_eq!(table.lines[1], skeletons[0]);
assert_eq!(table.lines[2], skeletons[1]);
assert!(table.lines[3].is_empty(), "spacer should be blank");
assert!(table.lines[3].is_empty());
assert_eq!(table.lines[4], footer);

// No-op when index out of bounds (returns false)
Expand Down
78 changes: 19 additions & 59 deletions src/commands/list/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ mod tests {
line1.push_styled(branch_ja.to_string(), Style::new().bold());
line1.pad_to(20); // Pad to width 20

assert_eq!(line1.width(), 20, "Japanese branch should pad to 20");
assert_eq!(line1.width(), 20);

// Case 2: Regular ASCII branch
let branch_ascii = "feature-test";
Expand All @@ -930,7 +930,7 @@ mod tests {
line2.push_styled(branch_ascii.to_string(), Style::new().bold());
line2.pad_to(20);

assert_eq!(line2.width(), 20, "ASCII branch should pad to 20");
assert_eq!(line2.width(), 20);

// Both should have the same visual width after padding
assert_eq!(
Expand Down Expand Up @@ -1042,7 +1042,7 @@ mod tests {
assert_eq!(without.width(), total);
let rendered_without = without.render();
let clean_without = rendered_without.ansi_strip().into_owned();
assert_eq!(clean_without, " ", "Should render as blank");
assert_eq!(clean_without, " ");

// With always_show_zeros=true, (0, 0) renders as "↑0 ↓0"
let with = format_diff_like_column(
Expand Down Expand Up @@ -1089,7 +1089,7 @@ mod tests {
line1.push_raw(status_with_emoji.to_string());
line1.pad_to(status_start + 6); // Pad to width 6 (typical Status column width)

assert_eq!(line1.width(), 6, "Status column with emoji should pad to 6");
assert_eq!(line1.width(), 6);

// Case 2: Status with only ASCII symbols (↑ is 1 column = 1 total)
let status_ascii = "↑";
Expand All @@ -1104,7 +1104,7 @@ mod tests {
line2.push_raw(status_ascii.to_string());
line2.pad_to(status_start2 + 6);

assert_eq!(line2.width(), 6, "Status column with ASCII should pad to 6");
assert_eq!(line2.width(), 6);

// Both should have the same visual width after padding
assert_eq!(
Expand All @@ -1127,7 +1127,7 @@ mod tests {
line3.push_raw(complex_status.to_string());
line3.pad_to(status_start3 + 10); // Pad to width 10

assert_eq!(line3.width(), 10, "Complex status should pad to 10");
assert_eq!(line3.width(), 10);
}

#[test]
Expand Down Expand Up @@ -1156,7 +1156,7 @@ mod tests {
);
let rendered1 = result1.render();
let clean1 = rendered1.ansi_strip().into_owned();
assert_eq!(clean1, " +53 -7", "Should be ' +53 -7'");
assert_eq!(clean1, " +53 -7");

// Test case 2: (33, 23) - both medium
let result2 = format_diff_like_column(
Expand All @@ -1176,7 +1176,7 @@ mod tests {
);
let rendered2 = result2.render();
let clean2 = rendered2.ansi_strip().into_owned();
assert_eq!(clean2, " +33 -23", "Should be ' +33 -23'");
assert_eq!(clean2, " +33 -23");

// Test case 3: (2, 2) - both small (needs padding)
let result3 = format_diff_like_column(
Expand All @@ -1196,7 +1196,7 @@ mod tests {
);
let rendered3 = result3.render();
let clean3 = rendered3.ansi_strip().into_owned();
assert_eq!(clean3, " +2 -2", "Should be ' +2 -2'");
assert_eq!(clean3, " +2 -2");

// Verify vertical alignment: the ones digits should be in the same column
// The ones digit should be at position 3 for all cases (with 2-digit allocation)
Expand Down Expand Up @@ -1268,16 +1268,8 @@ mod tests {
);
assert_eq!(overflow_result.width(), total);
let rendered = overflow_result.render();
assert!(
rendered.contains("+1") && rendered.contains('K'),
"Positive overflow should show +1K (may have styling), got: {}",
rendered
);
assert!(
rendered.contains("500"),
"Negative value should show normally when positive overflows, got: {}",
rendered
);
assert!(rendered.contains("+1") && rendered.contains('K'));
assert!(rendered.contains("500"));

// Case 3: Negative overflow
// Should show: "+500 -1K" (positive normal, negative with K suffix)
Expand All @@ -1298,16 +1290,8 @@ mod tests {
);
assert_eq!(overflow_result2.width(), total);
let rendered2 = overflow_result2.render();
assert!(
rendered2.contains("500"),
"Positive value should show normally when negative overflows, got: {}",
rendered2
);
assert!(
rendered2.contains("-1") && rendered2.contains('K'),
"Negative overflow should show -1K (may have styling), got: {}",
rendered2
);
assert!(rendered2.contains("500"));
assert!(rendered2.contains("-1") && rendered2.contains('K'));

// Case 4: Extreme overflow (>= 10K values show ∞ to avoid false precision)
let extreme_overflow = format_diff_like_column(
Expand All @@ -1331,16 +1315,8 @@ mod tests {
"100K overflow should fit in allocated width"
);
let extreme_rendered = extreme_overflow.render();
assert!(
extreme_rendered.contains("+∞"),
"100K+ overflow should show +∞ (may have styling), got: {}",
extreme_rendered
);
assert!(
extreme_rendered.contains("-∞"),
"100K+ overflow should show -∞ (may have styling), got: {}",
extreme_rendered
);
assert!(extreme_rendered.contains("+∞"));
assert!(extreme_rendered.contains("-∞"));

// Test overflow with Arrows variant (↑ and ↓)
let arrow_total = 7;
Expand All @@ -1364,16 +1340,8 @@ mod tests {
);
assert_eq!(arrow_overflow.width(), arrow_total);
let arrow_rendered = arrow_overflow.render();
assert!(
arrow_rendered.contains("↑1") && arrow_rendered.contains('K'),
"Arrow positive overflow should show ↑1K (may have styling), got: {}",
arrow_rendered
);
assert!(
arrow_rendered.contains("50"),
"Negative value should show normally when positive overflows, got: {}",
arrow_rendered
);
assert!(arrow_rendered.contains("↑1") && arrow_rendered.contains('K'));
assert!(arrow_rendered.contains("50"));

// Case 6: Arrow negative overflow
// Should show with K suffix
Expand All @@ -1394,15 +1362,7 @@ mod tests {
);
assert_eq!(arrow_overflow2.width(), arrow_total);
let arrow_rendered2 = arrow_overflow2.render();
assert!(
arrow_rendered2.contains("50"),
"Positive value should show normally when negative overflows, got: {}",
arrow_rendered2
);
assert!(
arrow_rendered2.contains("↓1") && arrow_rendered2.contains('K'),
"Arrow negative overflow should show ↓1K (may have styling), got: {}",
arrow_rendered2
);
assert!(arrow_rendered2.contains("50"));
assert!(arrow_rendered2.contains("↓1") && arrow_rendered2.contains('K'));
}
}
44 changes: 22 additions & 22 deletions src/commands/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,10 @@ mod tests {
let output = format_log_output_with_formatter(input, fixed_time_formatter);

// Should contain the hash and message
assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Fix bug"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Fix bug"));
// Should contain formatted time
assert!(output.contains("1h"), "output: {}", output);
assert!(output.contains("1h"));
}

#[test]
Expand All @@ -1153,10 +1153,10 @@ mod tests {
let output = format_log_output_with_formatter(input, fixed_time_formatter);

// Should contain the hash and message
assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("abc1234"));
// Stats should be accumulated: 10+3=13 insertions, 5+0=5 deletions
// The output should contain the stats in the formatted line
assert!(output.contains("Add feature"), "output: {}", output);
assert!(output.contains("Add feature"));
// Verify stats are present (green +13, red -5)
assert!(output.contains("+13"), "expected +13 in output: {}", output);
assert!(output.contains("-5"), "expected -5 in output: {}", output);
Expand All @@ -1172,10 +1172,10 @@ mod tests {
let output = format_log_output_with_formatter(input, fixed_time_formatter);

// Both commits should be in output
assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("def5678"), "output: {}", output);
assert!(output.contains("First commit"), "output: {}", output);
assert!(output.contains("Second commit"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("def5678"));
assert!(output.contains("First commit"));
assert!(output.contains("Second commit"));

// Output should be two lines (one per commit)
let lines: Vec<&str> = output.lines().collect();
Expand All @@ -1194,8 +1194,8 @@ mod tests {
let input = "abc1234\x1f1699999000\x1f Just a commit";
let output = format_log_output_with_formatter(input, fixed_time_formatter);

assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Just a commit"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Just a commit"));
}

#[test]
Expand All @@ -1205,8 +1205,8 @@ mod tests {
| 5\t2\tfile.rs";
let output = format_log_output_with_formatter(input, fixed_time_formatter);

assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Commit with graph"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Commit with graph"));
// Verify stats are present
assert!(output.contains("+5"), "expected +5 in output: {}", output);
assert!(output.contains("-2"), "expected -2 in output: {}", output);
Expand All @@ -1222,8 +1222,8 @@ mod tests {

// Binary files treated as 0 additions/deletions
// Should still format the commit line
assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Add image"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Add image"));
// Verify stats: 0 (binary) + 5 = 5 insertions, 0 deletions
assert!(output.contains("+5"), "expected +5 in output: {}", output);
}
Expand All @@ -1235,7 +1235,7 @@ mod tests {
let output = format_log_output_with_formatter(input, fixed_time_formatter);

// Should be empty since no valid commit lines (no FIELD_DELIM)
assert!(output.is_empty(), "output: {}", output);
assert!(output.is_empty());
}

#[test]
Expand All @@ -1245,7 +1245,7 @@ mod tests {
let output = format_log_output_with_formatter(input, fixed_time_formatter);

// Should output the line as-is since it's malformed (only one \x1f)
assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("abc1234"));
}

#[test]
Expand All @@ -1255,8 +1255,8 @@ mod tests {
0\t50\told_file.rs";
let output = format_log_output_with_formatter(input, fixed_time_formatter);

assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Remove old code"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Remove old code"));
// Should show deletions
assert!(output.contains("-50"), "expected -50 in output: {}", output);
}
Expand All @@ -1268,7 +1268,7 @@ mod tests {
1500\t800\tlarge_file.rs";
let output = format_log_output_with_formatter(input, fixed_time_formatter);

assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("abc1234"));
// Large numbers should use K notation
assert!(
output.contains("+1K") || output.contains("+1.5K"),
Expand All @@ -1284,8 +1284,8 @@ mod tests {
let stats = (10, 5);
let output = format_commit_line(commit_line, stats, &fixed_time_formatter);

assert!(output.contains("abc1234"), "output: {}", output);
assert!(output.contains("Test commit"), "output: {}", output);
assert!(output.contains("abc1234"));
assert!(output.contains("Test commit"));
assert!(output.contains("+10"), "expected +10 in output: {}", output);
assert!(output.contains("-5"), "expected -5 in output: {}", output);
assert!(output.contains("1h"), "expected time in output: {}", output);
Expand Down
12 changes: 6 additions & 6 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod tests {
let text = "Fix bug with parsing and more text here";
let result = truncate_to_width(text, 25);
println!("Normal truncation: '{}'", result);
assert!(result.ends_with('…'), "Should end with ellipsis");
assert!(result.ends_with('…'));
}

#[test]
Expand All @@ -136,7 +136,7 @@ mod tests {
let result = truncate_to_width(text, 25);
// Shows what happens when truncation lands on existing "..."
println!("ASCII ellipsis: '{}'", result);
assert!(result.ends_with('…'), "Should end with ellipsis");
assert!(result.ends_with('…'));
}

#[test]
Expand All @@ -145,7 +145,7 @@ mod tests {
let result = truncate_to_width(text, 25);
// Shows what happens when truncation lands on existing "…"
println!("Unicode ellipsis: '{}'", result);
assert!(result.ends_with('…'), "Should end with ellipsis");
assert!(result.ends_with('…'));
}

#[test]
Expand All @@ -160,14 +160,14 @@ mod tests {
fn test_truncate_exact_width() {
let text = "This is a very long message that needs truncation";
let result = truncate_to_width(text, 30);
assert!(result.ends_with('…'), "Should end with ellipsis");
assert!(result.ends_with('…'));
assert!(
!result.contains(" …"),
"Should not have space before ellipsis"
);
// Should truncate at exact width (mid-word if needed)
use unicode_width::UnicodeWidthStr;
assert_eq!(result.width(), 30, "Should fill exact width");
assert_eq!(result.width(), 30);
}

#[test]
Expand Down Expand Up @@ -196,7 +196,7 @@ mod tests {
use unicode_width::UnicodeWidthStr;
// Should truncate mid-word if no space found
assert!(result.width() <= 20, "Width should be <= 20");
assert!(result.ends_with('…'), "Should end with ellipsis");
assert!(result.ends_with('…'));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/git/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rstest::rstest;
/// Helper to parse a single worktree from porcelain output
fn parse_single(input: &str) -> Worktree {
let list = Worktree::parse_porcelain_list(input).expect("parse ok");
assert_eq!(list.len(), 1, "expected single worktree");
assert_eq!(list.len(), 1);
list.into_iter().next().unwrap()
}

Expand Down
Loading