mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
test(roadtrip): the assemble spec holds up under shared's stricter typecheck
noUncheckedIndexedAccess makes every index access optional, DriveLimits wants its two minute ceilings named even when they are null, and the distance unit is metric/imperial rather than a unit label.
This commit is contained in:
@@ -56,19 +56,19 @@ function assemble(stops: RoadtripStop[], legs: number[]) {
|
||||
const day: PlanDay = { dayId: 1, dayNumber: 1, date: '2026-06-01', title: null, stops };
|
||||
const allLegs: Record<string, RoutedLeg> = {};
|
||||
legs.forEach((km, i) => {
|
||||
allLegs[legKey(stops[i], stops[i + 1])] = leg(km);
|
||||
allLegs[legKey(stops[i]!, stops[i + 1]!)] = leg(km);
|
||||
});
|
||||
return assembleRoadtrip({
|
||||
plan: [day],
|
||||
quietDays: [],
|
||||
window: null,
|
||||
distanceUnit: 'km',
|
||||
distanceUnit: 'metric',
|
||||
allLegs,
|
||||
snapByDay: {},
|
||||
missedByDay: {},
|
||||
loading: false,
|
||||
// 600 km on a full battery, and no daily driving ceiling to muddy the warnings.
|
||||
limits: { rangeKm: 600 },
|
||||
limits: { rangeKm: 600, legMinutes: null, dayMinutes: null },
|
||||
vehicleKind: 'electric',
|
||||
connectDays: false,
|
||||
boundaries: [],
|
||||
@@ -77,7 +77,7 @@ function assemble(stops: RoadtripStop[], legs: number[]) {
|
||||
}
|
||||
|
||||
const rangeWarnings = (routes: ReturnType<typeof assemble>) =>
|
||||
routes.days[0].driveWarnings.filter((w) => w.code === 'range');
|
||||
routes.days[0]!.driveWarnings.filter((w) => w.code === 'range');
|
||||
|
||||
describe('assembleRoadtrip drive warnings', () => {
|
||||
it('ROADTRIP-ASSEMBLE-001: a charger at the end of an out-of-range leg answers for it', () => {
|
||||
|
||||
Reference in New Issue
Block a user