Extend IFlightLeg with transition and full equipment types
This commit is contained in:
@@ -13,6 +13,14 @@ import type {
|
||||
ISimpleFlight,
|
||||
IBoardResponse,
|
||||
IDaysResponse,
|
||||
IFlightTransitions,
|
||||
IFlightTransitionItem,
|
||||
FlightTransitionStatus,
|
||||
IMealItem,
|
||||
MealType,
|
||||
IOnBoardService,
|
||||
IAircraftInfo,
|
||||
IEquipmentFull,
|
||||
} from "./types.js";
|
||||
|
||||
/**
|
||||
@@ -206,3 +214,77 @@ describe("online-board types", () => {
|
||||
expect(resp.days).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("online-board types extension", () => {
|
||||
it("IFlightTransitionItem has start/end/status/isActual", () => {
|
||||
const item: IFlightTransitionItem = {
|
||||
start: { dayChange: { value: 0, title: "" }, local: "10:00", localTime: "10:00", tzOffset: 3, utc: "07:00" },
|
||||
end: { dayChange: { value: 0, title: "" }, local: "10:30", localTime: "10:30", tzOffset: 3, utc: "07:30" },
|
||||
status: "InProgress",
|
||||
isActual: true,
|
||||
};
|
||||
expect(item.status).toBe("InProgress");
|
||||
expect(item.isActual).toBe(true);
|
||||
});
|
||||
|
||||
it("FlightTransitionStatus accepts all 5 values", () => {
|
||||
const statuses: FlightTransitionStatus[] = [
|
||||
"Finished", "Expected", "InProgress", "Specified", "Scheduled",
|
||||
];
|
||||
expect(statuses).toHaveLength(5);
|
||||
});
|
||||
|
||||
it("IFlightTransitions has optional registration/boarding/deboarding", () => {
|
||||
const t: IFlightTransitions = {};
|
||||
expect(t.registration).toBeUndefined();
|
||||
expect(t.boarding).toBeUndefined();
|
||||
expect(t.deboarding).toBeUndefined();
|
||||
});
|
||||
|
||||
it("MealType accepts Economy/Comfort/Business/Special", () => {
|
||||
const meals: MealType[] = ["Economy", "Comfort", "Business", "Special"];
|
||||
expect(meals).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("IMealItem has type field", () => {
|
||||
const m: IMealItem = { type: "Economy" };
|
||||
expect(m.type).toBe("Economy");
|
||||
});
|
||||
|
||||
it("IOnBoardService has id, optional title, optional url", () => {
|
||||
const svc: IOnBoardService = { id: 4 };
|
||||
expect(svc.id).toBe(4);
|
||||
expect(svc.title).toBeUndefined();
|
||||
expect(svc.url).toBeUndefined();
|
||||
});
|
||||
|
||||
it("IAircraftInfo has optional title and onBoardServices", () => {
|
||||
const a: IAircraftInfo = { title: "Boeing 737", onBoardServices: [{ id: 1 }] };
|
||||
expect(a.title).toBe("Boeing 737");
|
||||
expect(a.onBoardServices).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("IEquipmentFull nests aircraft.scheduled/actual/configuration and meal[]", () => {
|
||||
const eq: IEquipmentFull = {
|
||||
aircraft: {
|
||||
scheduled: { title: "A320" },
|
||||
actual: { title: "A321", onBoardServices: [] },
|
||||
configuration: "C12Y138",
|
||||
},
|
||||
meal: [{ type: "Business" }],
|
||||
};
|
||||
expect(eq.aircraft?.scheduled?.title).toBe("A320");
|
||||
expect(eq.aircraft?.actual?.title).toBe("A321");
|
||||
expect(eq.aircraft?.configuration).toBe("C12Y138");
|
||||
expect(eq.meal?.[0]?.type).toBe("Business");
|
||||
});
|
||||
|
||||
it("IFlightLeg includes transition and extended equipment", () => {
|
||||
const leg: Partial<IFlightLeg> = {
|
||||
transition: { registration: { start: {} as never, end: {} as never, status: "Finished", isActual: true } },
|
||||
equipment: { name: "A320", aircraft: { actual: { title: "A320" } } },
|
||||
};
|
||||
expect(leg.transition?.registration?.status).toBe("Finished");
|
||||
expect(leg.equipment?.aircraft?.actual?.title).toBe("A320");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,17 +100,72 @@ export interface IFlightLegFlags {
|
||||
routeChanged: boolean;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Transition (registration/boarding/deboarding)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type FlightTransitionStatus =
|
||||
| "Finished"
|
||||
| "Expected"
|
||||
| "InProgress"
|
||||
| "Specified"
|
||||
| "Scheduled";
|
||||
|
||||
export interface IFlightTransitionItem {
|
||||
end: ITimesSet;
|
||||
start: ITimesSet;
|
||||
status: FlightTransitionStatus;
|
||||
isActual: boolean;
|
||||
}
|
||||
|
||||
export interface IFlightTransitions {
|
||||
registration?: IFlightTransitionItem;
|
||||
boarding?: IFlightTransitionItem;
|
||||
deboarding?: IFlightTransitionItem;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Equipment (aircraft + meal + on-board services)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type MealType = "Economy" | "Comfort" | "Business" | "Special";
|
||||
|
||||
export interface IMealItem {
|
||||
type: MealType;
|
||||
}
|
||||
|
||||
export interface IOnBoardService {
|
||||
id: number;
|
||||
title?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface IAircraftInfo {
|
||||
title?: string;
|
||||
onBoardServices?: IOnBoardService[];
|
||||
}
|
||||
|
||||
export interface IEquipmentFull {
|
||||
aircraft?: {
|
||||
scheduled?: IAircraftInfo;
|
||||
actual?: IAircraftInfo;
|
||||
configuration?: string;
|
||||
};
|
||||
meal?: IMealItem[];
|
||||
}
|
||||
|
||||
export interface IFlightLeg {
|
||||
arrival: IFlightLegArrivalStation;
|
||||
dayChange: number;
|
||||
departure: IFlightLegDepartureStation;
|
||||
equipment: { name?: string; code?: string };
|
||||
equipment: { name?: string; code?: string } & IEquipmentFull;
|
||||
flags: IFlightLegFlags;
|
||||
flyingTime: string;
|
||||
index: number;
|
||||
operatingBy: { carrier?: string; flightNumber?: string };
|
||||
status: FlightStatus;
|
||||
updated: string;
|
||||
transition?: IFlightTransitions;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user