use serde::{Deserialize, Serialize};

/// Tipo de viagem
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum TravelType {
    /// Viagem aérea
    Flight,
    /// Viagem terrestre (ônibus)
    Bus,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_travel_type_serialization() {
        let flight = TravelType::Flight;
        let json = serde_json::to_string(&flight).unwrap();
        assert_eq!(json, r#""flight""#);

        let bus = TravelType::Bus;
        let json = serde_json::to_string(&bus).unwrap();
        assert_eq!(json, r#""bus""#);
    }

    #[test]
    fn test_travel_type_deserialization() {
        let json = r#""flight""#;
        let travel_type: TravelType = serde_json::from_str(json).unwrap();
        assert_eq!(travel_type, TravelType::Flight);

        let json = r#""bus""#;
        let travel_type: TravelType = serde_json::from_str(json).unwrap();
        assert_eq!(travel_type, TravelType::Bus);
    }
}

