use super::*;

#[test]
fn category_folds_labels_and_keeps_the_rest_verbatim() {
    assert_eq!(AlertCategory::from_label("TFR"), AlertCategory::Tfr);
    assert_eq!(
        AlertCategory::from_label("CONVECTION_SIGMET"),
        AlertCategory::ConvectiveSigmet
    );
    assert_eq!(
        AlertCategory::from_label("AIRPORT_RUNWAY_RESTRICTION"),
        AlertCategory::AirportRunwayRestriction
    );
    assert_eq!(AlertCategory::from_label("UAS"), AlertCategory::Uas);
    assert_eq!(
        AlertCategory::from_label("SpaceJunk"),
        AlertCategory::Other("SpaceJunk".to_owned())
    );
}

#[test]
fn alert_builders_populate_the_optional_fields() {
    let alert = RouteAlert::new(AlertCategory::Tfr, "AIRSPACE …")
        .with_summary(Some("TFR near HARRISON, NJ".to_owned()))
        .with_distances(Some(0.0), Some(1.79));
    assert_eq!(alert.summary.as_deref(), Some("TFR near HARRISON, NJ"));
    assert_eq!(alert.distance_along_route_nm, Some(0.0));
    assert_eq!(alert.lateral_distance_nm, Some(1.79));
    assert!(alert.area.is_none());
}
