leptos-motion-core 0.3.3

Core animation engine for Leptos Motion
Documentation
//! Bundle size optimization tests using TDD approach
//!
//! These tests ensure that bundle size optimizations don't break functionality
//! while achieving the target bundle size goals.

#[cfg(feature = "leptos-integration")]
// WASM-specific test configuration - conditional compilation
#[cfg(feature = "web-sys")]
use wasm_bindgen_test::*;

#[cfg(feature = "web-sys")]
wasm_bindgen_test_configure!(run_in_browser);

/// Test that core animation functionality still works after bundle optimization
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_core_animation_functionality_after_optimization() {
    use crate::*;

    // Test that basic animation types still work
    let animation_value = AnimationValue::Number(1.0);
    assert_eq!(animation_value.to_string(), "1");

    // Test that easing functions still work
    let easing = Easing::EaseInOut;
    assert_eq!(easing.evaluate(0.5), 0.5);

    // Test that transition creation still works
    let transition = Transition {
        duration: Some(1.0),
        ease: Easing::EaseOut,
        ..Default::default()
    };
    assert_eq!(transition.duration, Some(1.0));
}

/// Test that minimal engine still works after dependency reduction
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_minimal_engine_after_optimization() {
    use crate::MinimalEngine;

    let _engine = MinimalEngine::new();
    // Engine should be created successfully
    assert!(true); // Basic creation test
}

/// Test that performance monitoring still works after optimization
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_performance_monitoring_after_optimization() {
    use crate::performance::*;

    let budget = PerformanceBudget::default();
    assert_eq!(budget.target_fps, 60.0);

    let monitor = PerformanceMonitor::new(budget);
    // Monitor should be created successfully
    assert!(true); // Basic creation test
}

/// Test that animation values still work after serde replacement
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_animation_values_after_serde_replacement() {
    use crate::*;

    // Test numeric values
    let num_value = AnimationValue::Number(42.0);
    assert_eq!(num_value.to_string(), "42");

    // Test pixel values
    let pixel_value = AnimationValue::Pixels(100.0);
    assert_eq!(pixel_value.to_string(), "100px");

    // Test transform values
    let transform_value = AnimationValue::Transform(Transform {
        x: Some(10.0),
        y: Some(20.0),
        scale_x: Some(1.5),
        scale_y: Some(1.5),
        rotate_z: Some(45.0),
        ..Default::default()
    });
    assert!(transform_value.to_string().contains("translateX(10px)"));
}

/// Test that gesture system still works after web-sys optimization
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_gesture_system_after_web_sys_optimization() {
    // This test will be implemented when we optimize web-sys dependencies
    // For now, just ensure the test structure is in place
    assert!(true);
}

/// Test that layout animations still work after optimization
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_layout_animations_after_optimization() {
    // This test will be implemented when we optimize layout dependencies
    // For now, just ensure the test structure is in place
    assert!(true);
}

/// Test bundle size targets (conceptual - actual measurement will be done externally)
#[cfg(feature = "leptos-integration")]
#[cfg_attr(feature = "web-sys", wasm_bindgen_test)]
#[cfg_attr(not(feature = "web-sys"), test)]
fn test_bundle_size_targets() {
    // This test documents our bundle size targets
    // Actual measurement will be done with external tools

    // Target: <50KB total bundle size
    // Target: <20KB core library
    // Target: <15KB individual crates

    // This test passes if the functionality tests pass
    // Bundle size measurement will be done separately
    assert!(true);
}