import { describe, it, expect } from 'vitest'; import { parsePrediction } from '$domain'; import type { PredictionStage } from '$domain'; const stages: PredictionStage[] = [ { stage: 'ascent', trajectory: [ { altitude: 0, datetime: '2026-01-01T00:00:00Z', latitude: 62.0, longitude: 129.0 }, { altitude: 30000, datetime: '2026-01-01T01:00:00Z', latitude: 62.1, longitude: 129.2 } ] }, { stage: 'descent', trajectory: [ { altitude: 30000, datetime: '2026-01-01T01:00:00Z', latitude: 62.1, longitude: 129.2 }, { altitude: 0, datetime: '2026-01-01T01:30:00Z', latitude: 62.05, longitude: 129.4 } ] } ]; describe('parsePrediction', () => { it('flattens ascent + descent into one flight_path', () => { const p = parsePrediction(stages); expect(p.flight_path).toHaveLength(4); expect(p.timestamps).toHaveLength(4); }); it('derives launch, burst, and landing points', () => { const p = parsePrediction(stages); expect(p.launch.latlng.lat).toBe(62.0); // ascent[0] expect(p.burst.latlng.alt).toBe(30000); // descent[0] expect(p.landing.latlng.lat).toBe(62.05); // descent[last] expect(p.flight_time).toBe(90 * 60); // 90 minutes, in seconds expect(p.profile).toBe('standard_profile'); }); it('throws when there are fewer than two stages', () => { expect(() => parsePrediction([stages[0]])).toThrow(); }); });