Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz committed Jul 26, 2021
1 parent 8304d0c commit 6d6a229
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl SpriteSheetAnimationState {
self.current_frame = 0;
} else {
self.current_frame = 0;
self.elapsed_in_frame = Duration::ZERO;
return true;
}

Expand Down Expand Up @@ -371,6 +372,19 @@ mod tests {
) {
assert!(state.update(&mut sprite_at_second_frame, &animation, frame_duration))
}

#[rstest]
fn returns_to_initial_state(
mut state: SpriteSheetAnimationState,
mut sprite_at_second_frame: TextureAtlasSprite,
animation: SpriteSheetAnimation,
frame_duration: Duration,
) {
state.update(&mut sprite_at_second_frame, &animation, frame_duration);
let expected_state = SpriteSheetAnimationState::default();
assert_eq!(state.current_frame, expected_state.current_frame);
assert_eq!(state.elapsed_in_frame, expected_state.elapsed_in_frame);
}
}
}
}

0 comments on commit 6d6a229

Please sign in to comment.