061ac1390c
С остальными КА мы не работаем, поэтому отсекаем их сразу на входе в loadData: фильтруем платформы по статусу и оставляем планы только для эксплуатируемых КА (по norad-id), иначе неoperational-аппарат вернулся бы fallback-строкой по плану в buildPlatformsForInterval.
31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { TguPlatform } from "../../model/tguTypes";
|
|
import { isOperationalPlatform, operationalSpacecraftIds } from "./tguTimelineMapper";
|
|
|
|
function platform(overrides: Partial<TguPlatform>): TguPlatform {
|
|
return { id: "x", noradId: 1, status: "OPERATIONAL", ...overrides };
|
|
}
|
|
|
|
describe("isOperationalPlatform", () => {
|
|
it("принимает только статус OPERATIONAL без учёта регистра и пробелов", () => {
|
|
expect(isOperationalPlatform(platform({ status: "OPERATIONAL" }))).toBe(true);
|
|
expect(isOperationalPlatform(platform({ status: " operational " }))).toBe(true);
|
|
expect(isOperationalPlatform(platform({ status: "STANDBY" }))).toBe(false);
|
|
expect(isOperationalPlatform(platform({ status: "LOST" }))).toBe(false);
|
|
expect(isOperationalPlatform(platform({ status: null }))).toBe(false);
|
|
expect(isOperationalPlatform(platform({ status: undefined }))).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("operationalSpacecraftIds", () => {
|
|
it("собирает norad-id в виде строк и пропускает платформы без norad-id", () => {
|
|
const ids = operationalSpacecraftIds([
|
|
platform({ noradId: 2 }),
|
|
platform({ noradId: 30 }),
|
|
platform({ noradId: null }),
|
|
platform({ noradId: undefined })
|
|
]);
|
|
expect(ids).toEqual(new Set(["2", "30"]));
|
|
});
|
|
});
|