krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

server/test/ll2.test.ts

04b2b1d914788057bcd20945b876847386eb8f65
moonrise/server/test/ll2.test.ts history · blame · raw

33 lines · 1387 bytes

1 symbol in this file
  • raw const, line 6
 1import assert from "node:assert/strict";
 2import { test } from "node:test";
 3import { normalize } from "../src/ll2.ts";
 4
 5// Trimmed from /2.3.0/launches/upcoming/?mode=normal on 2026-10-17.
 6const raw = {
 7  id: "3b430f81-0ff1-4d85-8a1a-cef0de326198",
 8  name: "Falcon 9 Block 5 | Bandwagon 5 (Dedicated Mid-Inclination Rideshare)",
 9  net: "2026-10-19T10:30:00Z",
10  window_start: "2026-10-19T10:30:00Z",
11  window_end: "2026-10-19T11:30:00Z",
12  last_updated: "2026-10-17T20:00:00Z",
13  status: { id: 1, name: "Go for Launch", abbrev: "Go" },
14  launch_service_provider: { name: "SpaceX", abbrev: "SpX" },
15  rocket: { configuration: { name: "Falcon 9", full_name: "Falcon 9 Block 5" } },
16  mission: { name: "Bandwagon 5", type: "Dedicated Rideshare", description: " Rideshare. ", orbit: { abbrev: "LEO" } },
17  pad: { name: "Space Launch Complex 40", latitude: "28.56194122", longitude: "-80.57735736", location: { name: "Cape Canaveral SFS, FL, USA" } },
18};
19
20test("normalizes a launch", () => {
21  const l = normalize(raw);
22  assert.equal(l.rocket, "Falcon 9 Block 5");
23  assert.equal(l.status, "Go");
24  assert.equal(l.orbit, "LEO");
25  assert.equal(l.missionDescription, "Rideshare.");
26  assert.equal(l.padLatitude, 28.56194122);
27});
28
29test("tolerates a missing mission", () => {
30  const l = normalize({ ...raw, mission: null });
31  assert.equal(l.mission, null);
32  assert.equal(l.orbit, null);
33});