2018-11-21 19:07:37 +01:00
|
|
|
const testDeparturesInDirection = async (cfg) => {
|
2018-07-07 21:26:40 +02:00
|
|
|
const {
|
|
|
|
test: t,
|
|
|
|
fetchDepartures,
|
|
|
|
fetchTrip,
|
|
|
|
id,
|
|
|
|
directionIds,
|
|
|
|
when,
|
2024-02-06 22:58:49 +01:00
|
|
|
validate,
|
|
|
|
} = cfg;
|
2018-07-07 21:26:40 +02:00
|
|
|
|
2021-12-29 21:11:07 +01:00
|
|
|
const res = await fetchDepartures(id, {
|
2018-07-07 21:26:40 +02:00
|
|
|
direction: directionIds[0],
|
2024-02-06 22:58:49 +01:00
|
|
|
when,
|
|
|
|
});
|
|
|
|
const {departures: deps} = res;
|
2021-12-29 21:11:07 +01:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
validate(t, res, 'departuresResponse', 'res');
|
2018-07-07 21:26:40 +02:00
|
|
|
|
|
|
|
for (let i = 0; i < deps.length; i++) {
|
2024-02-06 22:58:49 +01:00
|
|
|
const dep = deps[i];
|
|
|
|
const name = `deps[${i}]`;
|
2018-07-07 21:26:40 +02:00
|
|
|
|
2024-02-06 22:58:49 +01:00
|
|
|
const line = dep.line && dep.line.name;
|
2021-12-29 21:23:28 +01:00
|
|
|
const {trip} = await fetchTrip(dep.tripId, line, {
|
2024-02-06 22:58:49 +01:00
|
|
|
when, stopovers: true,
|
|
|
|
});
|
|
|
|
t.ok(trip.stopovers.some(st => st.stop.station && directionIds.includes(st.stop.station.id)
|
|
|
|
|| directionIds.includes(st.stop.id),
|
|
|
|
), `trip ${dep.tripId} of ${name} has no stopover at ${directionIds.join('/')}`);
|
2018-07-07 21:26:40 +02:00
|
|
|
}
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|
2018-07-07 21:26:40 +02:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
testDeparturesInDirection,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|