Skip to content

Commit 384d042

Browse files
committed
refactor: add countdown test helper
1 parent aedc39d commit 384d042

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/models/countdown.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ impl Countdown {
105105
self.total_paused += pause_time.elapsed();
106106
}
107107
}
108+
109+
#[cfg_attr(not(test), allow(dead_code))]
110+
pub fn fast_forward_for_test(&mut self, duration: Duration) {
111+
if let Some(start_time) = self.start_time {
112+
self.start_time = start_time.checked_sub(duration).or(Some(start_time));
113+
}
114+
if let Some(pause_time) = self.pause_time {
115+
self.pause_time = pause_time.checked_sub(duration).or(Some(pause_time));
116+
}
117+
}
108118
}
109119

110120
impl Default for Countdown {

0 commit comments

Comments
 (0)