//! Tests for defaults module

use crate::init::defaults::{get_template_defaults, template_has_node};

#[test]
fn test_get_template_defaults_rover() {
    let available = vec![
        "speaker".to_string(),
        "listener".to_string(),
        "motor".to_string(),
        "imu".to_string(),
        "camera".to_string(),
    ];
    let defaults = get_template_defaults(&Some("rover".to_string()), &available);

    assert_eq!(defaults.len(), 5);
    assert!(defaults[0]); // speaker - included
    assert!(defaults[1]); // listener - included
    assert!(defaults[2]); // motor - included
    assert!(defaults[3]); // imu - included
    assert!(!defaults[4]); // camera - not included
}

#[test]
fn test_get_template_defaults_basic() {
    let available = vec!["speaker".to_string(), "listener".to_string(), "motor".to_string()];
    let defaults = get_template_defaults(&Some("basic".to_string()), &available);

    assert_eq!(defaults.len(), 3);
    assert!(defaults[0]); // speaker - included
    assert!(defaults[1]); // listener - included
    assert!(!defaults[2]); // motor - not included
}

#[test]
fn test_get_template_defaults_invalid() {
    let available = vec!["speaker".to_string(), "listener".to_string()];
    let defaults = get_template_defaults(&Some("invalid".to_string()), &available);

    // Should fall back to basic defaults
    assert!(defaults[0]); // speaker
    assert!(defaults[1]); // listener
}

#[test]
fn test_template_has_node() {
    assert!(template_has_node("rover", "motor"));
    assert!(template_has_node("rover", "imu"));
    assert!(!template_has_node("rover", "camera"));
    assert!(!template_has_node("basic", "motor"));
    assert!(template_has_node("basic", "speaker"));
}
