31 lines
984 B
TypeScript
31 lines
984 B
TypeScript
import { content } from "@deadhead/content";
|
|
import { describe, expect, it } from "vitest";
|
|
import { locationPosition, routeDistance } from "../src/index";
|
|
|
|
const earth = content.location("earth")!;
|
|
const moon = content.location("moon")!;
|
|
|
|
// Step 15.2 (decision 0.5.93): positions and distances take no time; they never change.
|
|
describe("route distance", () => {
|
|
it("keeps Earth→Moon under 1 million km", () => {
|
|
expect(routeDistance(earth, moon)).toBeLessThan(1);
|
|
});
|
|
|
|
it("is symmetric", () => {
|
|
for (const a of content.locations) {
|
|
for (const b of content.locations) {
|
|
expect(routeDistance(a, b)).toBe(routeDistance(b, a));
|
|
}
|
|
}
|
|
});
|
|
|
|
it("returns the same value for the same inputs, every time", () => {
|
|
for (const a of content.locations) {
|
|
expect(locationPosition(a)).toEqual(locationPosition(a));
|
|
for (const b of content.locations) {
|
|
expect(routeDistance(a, b)).toBe(routeDistance(a, b));
|
|
}
|
|
}
|
|
});
|
|
});
|