church-core/tests/calendar_test.rs
RTSDA 4d6b23beb3
Some checks are pending
iOS UniFFI Build / build-ios (push) Waiting to run
Initial commit: Church Core Rust library
Add church management API library with cross-platform support for iOS, Android, and WASM.
Features include event management, bulletin handling, contact forms, and authentication.
2025-08-16 19:25:01 -04:00

73 lines
2.5 KiB
Rust

use church_core::create_calendar_event_data;
#[test]
fn test_calendar_event_parsing() {
// Test with various timestamp formats that might come from the iOS app
// Test 1: ISO 8601 with timezone
let event_with_tz = r#"{
"title": "Test Event",
"description": "Test Description",
"location": "Test Location",
"start_time": "2025-01-15T14:30:00-05:00",
"end_time": "2025-01-15T16:00:00-05:00"
}"#;
println!("🧪 Testing ISO 8601 with timezone:");
let result1 = create_calendar_event_data(event_with_tz.to_string());
println!("Result: {}", result1);
// Test 2: ISO 8601 without timezone
let event_no_tz = r#"{
"title": "Test Event",
"description": "Test Description",
"location": "Test Location",
"start_time": "2025-01-15T14:30:00",
"end_time": "2025-01-15T16:00:00"
}"#;
println!("\n🧪 Testing ISO 8601 without timezone:");
let result2 = create_calendar_event_data(event_no_tz.to_string());
println!("Result: {}", result2);
// Test 3: Date with space separator
let event_space = r#"{
"title": "Test Event",
"description": "Test Description",
"location": "Test Location",
"start_time": "2025-01-15 14:30:00",
"end_time": "2025-01-15 16:00:00"
}"#;
println!("\n🧪 Testing space-separated format:");
let result3 = create_calendar_event_data(event_space.to_string());
println!("Result: {}", result3);
// Test 4: camelCase field names (Swift encoding style)
let event_camel_case = r#"{
"title": "Test Event",
"description": "Test Description",
"location": "Test Location",
"startTime": "2025-01-15T14:30:00",
"endTime": "2025-01-15T16:00:00"
}"#;
println!("\n🧪 Testing camelCase field names:");
let result4 = create_calendar_event_data(event_camel_case.to_string());
println!("Result: {}", result4);
// Test 5: What might actually come from iOS encoding of ChurchEvent
let event_ios_style = r#"{
"id": "test123",
"title": "Test Event",
"description": "Test Description",
"startTime": "2025-01-15T14:30:00Z",
"endTime": "2025-01-15T16:00:00Z",
"location": "Test Location",
"category": "general"
}"#;
println!("\n🧪 Testing iOS-style encoding:");
let result5 = create_calendar_event_data(event_ios_style.to_string());
println!("Result: {}", result5);
}