test(engine): add boundary tests for format_secs and pause toggle cycle
leaderboard_plugin: format_secs was missing the 60-second crossing boundary (1:00 vs 60s), the zero case (0s), and leading-zero padding verification (1:05 not 1:5). pause_plugin: added third-press test confirming the Esc toggle is symmetric across multiple pause/resume cycles. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -586,4 +586,25 @@ mod tests {
|
||||
fn format_secs_above_minute() {
|
||||
assert_eq!(format_secs(183), "3:03");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_secs_zero() {
|
||||
assert_eq!(format_secs(0), "0s");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_secs_59_stays_below_minute() {
|
||||
assert_eq!(format_secs(59), "59s");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_secs_60_crosses_into_minutes() {
|
||||
assert_eq!(format_secs(60), "1:00");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_secs_pads_seconds_with_leading_zero() {
|
||||
// 65 seconds = 1:05, not 1:5
|
||||
assert_eq!(format_secs(65), "1:05");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,4 +151,28 @@ mod tests {
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toggle_is_symmetric_for_multiple_cycles() {
|
||||
let mut app = headless_app();
|
||||
// Third press re-pauses after resume.
|
||||
press_esc(&mut app);
|
||||
app.update();
|
||||
press_esc(&mut app);
|
||||
app.update();
|
||||
press_esc(&mut app);
|
||||
app.update();
|
||||
assert!(
|
||||
app.world().resource::<PausedResource>().0,
|
||||
"third Esc must re-pause"
|
||||
);
|
||||
assert_eq!(
|
||||
app.world_mut()
|
||||
.query::<&PauseScreen>()
|
||||
.iter(app.world())
|
||||
.count(),
|
||||
1,
|
||||
"third Esc must re-spawn PauseScreen"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user