diff --git a/crates/horizon-client/src/mobs/armadillo.rs b/crates/horizon-client/src/mobs/armadillo.rs index 8837d8cf8..1deb7f11b 100644 --- a/crates/horizon-client/src/mobs/armadillo.rs +++ b/crates/horizon-client/src/mobs/armadillo.rs @@ -405,3 +405,43 @@ impl Goal for Rolled { scared(m) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::mobs::sensor_scan_tests::kind; + use std::sync::Arc; + + /// An armadillo on the ground. + fn armadillo() -> Mob { + let mut kind = kind(); + let k = Arc::make_mut(&mut kind); + k.id = "minecraft:armadillo".into(); + k.species = Species::Armadillo; + let mut m = Mob::new(1, kind, Vec3::ZERO, 0.0); + m.on_ground = true; + m + } + + #[test] + fn a_hit_rolls_it_up_into_a_ball() { + // Armadillo.actuallyHurt: a hit by a living thing curls it up and + // keeps the danger in mind for 80 ticks, so the model shows the + // shell instead of the armadillo (#2759). + let mut m = armadillo(); + after_hurt(&mut m, &Damage::player([0.0, 0.0, 0.0])); + assert_eq!(state(&m), ROLLING); + // Armadillo.rollUp: the roll sound. + assert!( + m.outbox + .iter() + .any(|e| matches!(e, MobEvent::Sound(s, ..) if *s == "entity.armadillo.roll")), + "the roll plays its sound" + ); + // ArmadilloState.shouldHideInShell: the shell shows after five ticks. + for _ in 0..6 { + tick(&mut m); + } + assert!(hiding_in_shell(&m), "the model shows the shell"); + } +}