From bf150f11f16b14332cf7870ef2f15b7c4abb6f57 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Apr 2026 04:06:43 +0000 Subject: [PATCH] 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 --- solitaire_engine/src/leaderboard_plugin.rs | 21 +++++++++++++++++++ solitaire_engine/src/pause_plugin.rs | 24 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/solitaire_engine/src/leaderboard_plugin.rs b/solitaire_engine/src/leaderboard_plugin.rs index aa2649e..07830e3 100644 --- a/solitaire_engine/src/leaderboard_plugin.rs +++ b/solitaire_engine/src/leaderboard_plugin.rs @@ -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"); + } } diff --git a/solitaire_engine/src/pause_plugin.rs b/solitaire_engine/src/pause_plugin.rs index 105a46e..f5ed585 100644 --- a/solitaire_engine/src/pause_plugin.rs +++ b/solitaire_engine/src/pause_plugin.rs @@ -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::().0, + "third Esc must re-pause" + ); + assert_eq!( + app.world_mut() + .query::<&PauseScreen>() + .iter(app.world()) + .count(), + 1, + "third Esc must re-spawn PauseScreen" + ); + } }