use openfut_bridge::{capture::CapturedRequest, mapper::map_to_core}; #[test] fn test_known_endpoint_maps_to_core() { let mapping = map_to_core("POST", "/ut/auth"); assert!(mapping.is_some()); let m = mapping.unwrap(); assert_eq!(m.core_path, "/auth/local"); } #[test] fn test_unknown_endpoint_returns_none() { let mapping = map_to_core("GET", "/ut/game/fut/some/unknown/path"); assert!(mapping.is_none()); } #[test] fn test_capture_serializes_cleanly() { let capture = CapturedRequest::new( "GET", "/ut/game/fut/user/settings", None, vec![("user-agent".into(), "FIFA23/1.0".into())], None, ); let json = serde_json::to_string(&capture).expect("serialize"); let back: CapturedRequest = serde_json::from_str(&json).expect("deserialize"); assert_eq!(back.path, "/ut/game/fut/user/settings"); assert_eq!(back.method, "GET"); assert!(back.mapped_to_core.is_none()); assert!(back.response_status.is_none()); } #[test] fn test_capture_with_response() { let capture = CapturedRequest::new( "POST", "/ut/auth", None, vec![], Some(r#"{"token":"abc"}"#.into()), ) .with_response(200, Some(r#"{"status":"ok"}"#.into())); assert_eq!(capture.response_status, Some(200)); assert!(capture.response_body.is_some()); }