use super::*;

#[test]
fn summarizes_runtime_fixture() {
    let fixture = serde_json::json!({
        "format_version": 1,
        "fixture_id": "runtime-fixture-test",
        "source": { "kind": "synthetic" },
        "state": {
            "calendar": {
                "year": 1830,
                "month_slot": 0,
                "phase_slot": 0,
                "tick_slot": 0
            },
            "world_flags": {
                "sandbox": false
            },
            "companies": [],
            "event_runtime_records": []
        },
        "commands": [
            {
                "kind": "advance_to",
                "calendar": {
                    "year": 1830,
                    "month_slot": 0,
                    "phase_slot": 0,
                    "tick_slot": 3
                }
            }
        ],
        "expected_summary": {
            "calendar": {
                "year": 1830,
                "month_slot": 0,
                "phase_slot": 0,
                "tick_slot": 3
            },
            "world_flag_count": 1,
            "company_count": 0,
            "event_runtime_record_count": 0,
            "total_company_cash": 0
        },
        "expected_state_fragment": {
            "calendar": {
                "tick_slot": 3
            },
            "world_flags": {
                "sandbox": false
            }
        }
    });
    let path = write_temp_json("runtime-fixture", &fixture);

    summarize_fixture(&path).expect("fixture summary should succeed");

    let _ = fs::remove_file(path);
}

#[test]
fn summarizes_snapshot_backed_fixture_with_packed_event_collection() {
    let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("../../fixtures/runtime/packed-event-collection-from-snapshot.json");

    summarize_fixture(&fixture_path)
        .expect("snapshot-backed packed-event fixture should summarize");
}

#[test]
fn summarizes_snapshot_backed_fixture_with_imported_packed_event_record() {
    let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .join("../../fixtures/runtime/packed-event-record-import-from-snapshot.json");

    summarize_fixture(&fixture_path)
        .expect("snapshot-backed imported packed-event fixture should summarize");
}
