#[cfg(test)]
mod tests {
use crate::*;
use std::collections::HashMap;
#[test]
fn test_basic_types_creation() {
let handle = AnimationHandle(123);
assert_eq!(handle.0, 123);
let number_value = AnimationValue::Number(42.0);
match number_value {
AnimationValue::Number(n) => assert_eq!(n, 42.0),
_ => panic!("Expected Number variant"),
}
let string_value = AnimationValue::String("test".to_string());
match string_value {
AnimationValue::String(s) => assert_eq!(s, "test"),
_ => panic!("Expected String variant"),
}
}
#[test]
fn test_animation_target_creation() {
let mut target = HashMap::new();
target.insert("opacity".to_string(), AnimationValue::Number(1.0));
target.insert("scale".to_string(), AnimationValue::Number(1.2));
target.insert(
"color".to_string(),
AnimationValue::String("#ff0000".to_string()),
);
assert_eq!(target.len(), 3);
assert!(target.contains_key("opacity"));
assert!(target.contains_key("scale"));
assert!(target.contains_key("color"));
if let Some(AnimationValue::Number(opacity)) = target.get("opacity") {
assert_eq!(*opacity, 1.0);
} else {
panic!("Expected opacity to be a number");
}
}
#[test]
fn test_transition_creation() {
let transition = Transition {
duration: Some(1.0),
ease: Easing::Linear,
delay: Some(0.1),
repeat: RepeatConfig::Never,
..Default::default()
};
assert_eq!(transition.duration, Some(1.0));
assert_eq!(transition.delay, Some(0.1));
assert_eq!(transition.ease, Easing::Linear);
}
#[test]
fn test_minimal_engine_creation() {
let engine = MinimalEngine::new();
assert_eq!(engine.active_count(), 0);
}
#[test]
fn test_simplified_engine_creation() {
let _engine = SimplifiedAnimationEngine::new();
}
#[test]
fn test_error_types() {
let error = AnimationError::InvalidValue("test error".to_string());
match error {
AnimationError::InvalidValue(msg) => assert_eq!(msg, "test error"),
_ => panic!("Expected InvalidValue error"),
}
}
#[cfg(feature = "leptos-integration")]
#[test]
fn test_motion_values_creation() {
use crate::values::*;
let motion_number = MotionNumber::new(42.0);
assert_eq!(motion_number.get(), 42.0);
let motion_transform = MotionTransform::identity();
let transform = motion_transform.get();
assert!(transform.is_identity());
}
}