pretty-print fixtures

This commit is contained in:
Traines 2025-01-11 18:41:16 +00:00
parent 60656b0119
commit 32792507ba
10 changed files with 6704 additions and 10 deletions

View file

@ -15,7 +15,7 @@ const createFakeWalkingLeg = (prevLeg, leg) => {
fakeWalkingLeg.walking = true; fakeWalkingLeg.walking = true;
fakeWalkingLeg.distance = null; fakeWalkingLeg.distance = null;
return fakeWalkingLeg; return fakeWalkingLeg;
} };
const parseLocationsFromCtxRecon = (ctx, j) => { const parseLocationsFromCtxRecon = (ctx, j) => {
return (j.ctxRecon || j.kontext) return (j.ctxRecon || j.kontext)
@ -36,7 +36,7 @@ const parseJourney = (ctx, jj) => { // j = raw journey
const legs = []; const legs = [];
for (const l of j.verbindungsAbschnitte) { for (const l of j.verbindungsAbschnitte) {
const leg = profile.parseJourneyLeg(ctx, l, null, fallbackLocations); const leg = profile.parseJourneyLeg(ctx, l, null, fallbackLocations);
if (legs.length > 0 && !legs[legs.length-1].walking && !leg.walking) { if (legs.length > 0 && !legs[legs.length - 1].walking && !leg.walking) {
const fakeWalkingLeg = createFakeWalkingLeg(legs[legs.length - 1], leg); const fakeWalkingLeg = createFakeWalkingLeg(legs[legs.length - 1], leg);
legs.push(fakeWalkingLeg); legs.push(fakeWalkingLeg);
} }

View file

@ -7,8 +7,8 @@ import tap from 'tap';
import {createClient} from '../index.js'; import {createClient} from '../index.js';
import {profile as rawProfile} from '../p/db/index.js'; import {profile as rawProfile} from '../p/db/index.js';
const res = require('./fixtures/db-arrivals.json'); const res = require('./fixtures/dbris-arrivals.json');
import {dbArrivals as expected} from './fixtures/db-arrivals.js'; import {dbArrivals as expected} from './fixtures/dbris-arrivals.js';
const client = createClient(rawProfile, 'public-transport/hafas-client:test', {enrichStations: false}); const client = createClient(rawProfile, 'public-transport/hafas-client:test', {enrichStations: false});
const {profile} = client; const {profile} = client;

View file

@ -1 +1,118 @@
{"isArrival":false,"evaNo":"8000365","stationName":"Dombühl","items":[{"station":{"evaNo":"8000365","name":"Dombühl","canceled":false},"train":{"journeyId":"20241212-d1494ce6-1a01-38de-bf84-c0bceb12f503","category":"RE","type":"REGIONAL_TRAIN","no":88617,"lineName":"90"},"category":"REGIONAL","time":"2024-12-12T11:34:00.000Z","timePredicted":"2024-12-12T11:34:00.000Z","diff":0,"timeType":"PREVIEW","platform":"3","platformPredicted":"3","administration":{"id":"GARE","operatorCode":"RE","operatorName":"Arverio Baden-Württemberg (RE)"},"canceled":false,"departureId":"8000365_D_1","destination":{"evaNo":"8000284","name":"Nürnberg Hbf","canceled":false}},{"station":{"evaNo":"682943","name":"Bahnhof, Dombühl","canceled":false},"train":{"journeyId":"20241212-abd01ce0-cca3-3759-aa4b-410ea4d0a720","category":"Bus","type":"BUS","no":2221,"lineName":"813"},"category":"BUS","time":"2024-12-12T11:50:00.000Z","timePredicted":"2024-12-12T11:50:00.000Z","diff":0,"timeType":"SCHEDULE","platform":"","platformPredicted":"","administration":{"id":"vgn063","operatorCode":"DPN","operatorName":"Nahreisezug"},"canceled":false,"departureId":"682943_D_1","destination":{"evaNo":"676542","name":"Gymnasium, Dinkelsbühl","canceled":false}},{"station":{"evaNo":"682943","name":"Bahnhof, Dombühl","canceled":false},"train":{"journeyId":"20241212-ab6272a5-4bf6-32c1-9344-b47e1fc49eeb","category":"Bus","type":"BUS","no":2177,"lineName":"807"},"category":"BUS","time":"2024-12-12T11:50:00.000Z","timePredicted":"2024-12-12T11:50:00.000Z","diff":0,"timeType":"SCHEDULE","platform":"","platformPredicted":"","administration":{"id":"vgn063","operatorCode":"DPN","operatorName":"Nahreisezug"},"canceled":false,"departureId":"682943_D_1","destination":{"evaNo":"683407","name":"Bahnhof, Rothenburg ob der Tauber","canceled":false}}],"availableTransports":[{"id":"REGIONAL","text":"Regional"},{"id":"BUS","text":"Bus"}],"timeStart":"2024-12-12T11:33:30.000Z","timeEnd":"2024-12-12T12:03:30.000Z"} {
"isArrival": false,
"evaNo": "8000365",
"stationName": "Dombühl",
"items": [
{
"station": {
"evaNo": "8000365",
"name": "Dombühl",
"canceled": false
},
"train": {
"journeyId": "20241212-d1494ce6-1a01-38de-bf84-c0bceb12f503",
"category": "RE",
"type": "REGIONAL_TRAIN",
"no": 88617,
"lineName": "90"
},
"category": "REGIONAL",
"time": "2024-12-12T11:34:00.000Z",
"timePredicted": "2024-12-12T11:34:00.000Z",
"diff": 0,
"timeType": "PREVIEW",
"platform": "3",
"platformPredicted": "3",
"administration": {
"id": "GARE",
"operatorCode": "RE",
"operatorName": "Arverio Baden-Württemberg (RE)"
},
"canceled": false,
"departureId": "8000365_D_1",
"destination": {
"evaNo": "8000284",
"name": "Nürnberg Hbf",
"canceled": false
}
},
{
"station": {
"evaNo": "682943",
"name": "Bahnhof, Dombühl",
"canceled": false
},
"train": {
"journeyId": "20241212-abd01ce0-cca3-3759-aa4b-410ea4d0a720",
"category": "Bus",
"type": "BUS",
"no": 2221,
"lineName": "813"
},
"category": "BUS",
"time": "2024-12-12T11:50:00.000Z",
"timePredicted": "2024-12-12T11:50:00.000Z",
"diff": 0,
"timeType": "SCHEDULE",
"platform": "",
"platformPredicted": "",
"administration": {
"id": "vgn063",
"operatorCode": "DPN",
"operatorName": "Nahreisezug"
},
"canceled": false,
"departureId": "682943_D_1",
"destination": {
"evaNo": "676542",
"name": "Gymnasium, Dinkelsbühl",
"canceled": false
}
},
{
"station": {
"evaNo": "682943",
"name": "Bahnhof, Dombühl",
"canceled": false
},
"train": {
"journeyId": "20241212-ab6272a5-4bf6-32c1-9344-b47e1fc49eeb",
"category": "Bus",
"type": "BUS",
"no": 2177,
"lineName": "807"
},
"category": "BUS",
"time": "2024-12-12T11:50:00.000Z",
"timePredicted": "2024-12-12T11:50:00.000Z",
"diff": 0,
"timeType": "SCHEDULE",
"platform": "",
"platformPredicted": "",
"administration": {
"id": "vgn063",
"operatorCode": "DPN",
"operatorName": "Nahreisezug"
},
"canceled": false,
"departureId": "682943_D_1",
"destination": {
"evaNo": "683407",
"name": "Bahnhof, Rothenburg ob der Tauber",
"canceled": false
}
}
],
"availableTransports": [
{
"id": "REGIONAL",
"text": "Regional"
},
{
"id": "BUS",
"text": "Bus"
}
],
"timeStart": "2024-12-12T11:33:30.000Z",
"timeEnd": "2024-12-12T12:03:30.000Z"
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,97 @@
{"bahnhofstafelAbfahrtPositionen":[{"zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#929785#TA#1#DA#291224#1S#374704#1T#1502#LS#465246#LT#1530#PU#81#RT#1#CA#rfb#ZE#9870#ZB#RUF 9870#PC#9#FR#374704#FT#1502#TO#465246#TT#1530#","kurztext":"RUF","mitteltext":"RUF 9870","abfrageOrt":{"name":"Bahnhof, Rothenburg ob der Tauber","locationId":"A=1@O=Bahnhof, Rothenburg ob der Tauber@X=10191107@Y=49377189@U=81@L=374704@","evaNr":"374704","stationId":"5393"},"richtung":"ZOB, Creglingen","echtzeitNotizen":[],"abgangsDatum":"2024-12-29T15:02:00+01:00","produktGattung":"ANRUFPFLICHTIGEVERKEHRE"},{"gleis":"1","zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#214076#TA#1#DA#291224#1S#8005190#1T#1505#LS#8000091#LT#1520#PU#81#RT#1#CA#RB#ZE#58904#ZB#RB 58904#PC#3#FR#8005190#FT#1505#TO#8000091#TT#1520#","kurztext":"RB","mitteltext":"RB 82","abfrageOrt":{"name":"Rothenburg ob der Tauber","locationId":"A=1@O=Rothenburg ob der Tauber@X=10190702@Y=49376686@U=81@L=8005190@i=U×008022698@","evaNr":"8005190","stationId":"5393"},"richtung":"Steinach(bei Rothenburg ob der Tauber)","echtzeitNotizen":[],"abgangsDatum":"2024-12-29T15:05:00+01:00","produktGattung":"RB","ezAbgangsDatum":"2024-12-29T15:05:00+01:00"},{"zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#863886#TA#3#DA#291224#1S#682943#1T#1450#LS#683407#LT#1531#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#682943#FT#1450#TO#683407#TT#1531#","kurztext":"Bus","mitteltext":"Bus 807","abfrageOrt":{"name":"Schlachthof, Rothenburg ob der Tauber","locationId":"A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@","evaNr":"680433"},"richtung":"Bahnhof, Rothenburg ob der Tauber","echtzeitNotizen":[],"abgangsDatum":"2024-12-29T15:30:00+01:00","produktGattung":"BUS"},{"zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#863865#TA#0#DA#291224#1S#683407#1T#1532#LS#682943#LT#1624#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#683407#FT#1532#TO#682943#TT#1624#","kurztext":"Bus","mitteltext":"Bus 807","abfrageOrt":{"name":"Bahnhof, Rothenburg ob der Tauber","locationId":"A=1@O=Bahnhof, Rothenburg ob der Tauber@X=10190711@Y=49377180@U=81@L=683407@","evaNr":"683407","stationId":"5393"},"richtung":"Bahnhof, Dombühl","echtzeitNotizen":[],"abgangsDatum":"2024-12-29T15:32:00+01:00","produktGattung":"BUS"},{"zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#863865#TA#0#DA#291224#1S#683407#1T#1532#LS#682943#LT#1624#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#683407#FT#1532#TO#682943#TT#1624#","kurztext":"Bus","mitteltext":"Bus 807","abfrageOrt":{"name":"Schlachthof, Rothenburg ob der Tauber","locationId":"A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@","evaNr":"680433"},"richtung":"Bahnhof, Dombühl","echtzeitNotizen":[],"abgangsDatum":"2024-12-29T15:33:00+01:00","produktGattung":"BUS"},{"zuglaufId":"2|#VN#1#ST#1734722398#PI#1#ZI#864022#TA#1#DA#291224#1S#677019#1T#1458#LS#683407#LT#1548#PU#81#RT#1#CA#Bus#ZE#817#ZB#Bus 817#PC#5#FR#677019#FT#1458#TO#683407#TT#1548#","kurztext":"Bus","mitteltext":"Bus 817","abfrageOrt":{"name":"Schlachthof, Rothenburg ob der Tauber","locationId":"A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@","evaNr":"680433"},"richtung":"Bahnhof, Rothenburg ob der Tauber","echtzeitNotizen":[{"text":"Halt entfällt"}],"abgangsDatum":"2024-12-29T15:47:00+01:00","produktGattung":"BUS"}]} {
"bahnhofstafelAbfahrtPositionen": [
{
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#929785#TA#1#DA#291224#1S#374704#1T#1502#LS#465246#LT#1530#PU#81#RT#1#CA#rfb#ZE#9870#ZB#RUF 9870#PC#9#FR#374704#FT#1502#TO#465246#TT#1530#",
"kurztext": "RUF",
"mitteltext": "RUF 9870",
"abfrageOrt": {
"name": "Bahnhof, Rothenburg ob der Tauber",
"locationId": "A=1@O=Bahnhof, Rothenburg ob der Tauber@X=10191107@Y=49377189@U=81@L=374704@",
"evaNr": "374704",
"stationId": "5393"
},
"richtung": "ZOB, Creglingen",
"echtzeitNotizen": [],
"abgangsDatum": "2024-12-29T15:02:00+01:00",
"produktGattung": "ANRUFPFLICHTIGEVERKEHRE"
},
{
"gleis": "1",
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#214076#TA#1#DA#291224#1S#8005190#1T#1505#LS#8000091#LT#1520#PU#81#RT#1#CA#RB#ZE#58904#ZB#RB 58904#PC#3#FR#8005190#FT#1505#TO#8000091#TT#1520#",
"kurztext": "RB",
"mitteltext": "RB 82",
"abfrageOrt": {
"name": "Rothenburg ob der Tauber",
"locationId": "A=1@O=Rothenburg ob der Tauber@X=10190702@Y=49376686@U=81@L=8005190@i=U×008022698@",
"evaNr": "8005190",
"stationId": "5393"
},
"richtung": "Steinach(bei Rothenburg ob der Tauber)",
"echtzeitNotizen": [],
"abgangsDatum": "2024-12-29T15:05:00+01:00",
"produktGattung": "RB",
"ezAbgangsDatum": "2024-12-29T15:05:00+01:00"
},
{
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#863886#TA#3#DA#291224#1S#682943#1T#1450#LS#683407#LT#1531#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#682943#FT#1450#TO#683407#TT#1531#",
"kurztext": "Bus",
"mitteltext": "Bus 807",
"abfrageOrt": {
"name": "Schlachthof, Rothenburg ob der Tauber",
"locationId": "A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@",
"evaNr": "680433"
},
"richtung": "Bahnhof, Rothenburg ob der Tauber",
"echtzeitNotizen": [],
"abgangsDatum": "2024-12-29T15:30:00+01:00",
"produktGattung": "BUS"
},
{
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#863865#TA#0#DA#291224#1S#683407#1T#1532#LS#682943#LT#1624#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#683407#FT#1532#TO#682943#TT#1624#",
"kurztext": "Bus",
"mitteltext": "Bus 807",
"abfrageOrt": {
"name": "Bahnhof, Rothenburg ob der Tauber",
"locationId": "A=1@O=Bahnhof, Rothenburg ob der Tauber@X=10190711@Y=49377180@U=81@L=683407@",
"evaNr": "683407",
"stationId": "5393"
},
"richtung": "Bahnhof, Dombühl",
"echtzeitNotizen": [],
"abgangsDatum": "2024-12-29T15:32:00+01:00",
"produktGattung": "BUS"
},
{
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#863865#TA#0#DA#291224#1S#683407#1T#1532#LS#682943#LT#1624#PU#81#RT#1#CA#Bus#ZE#807#ZB#Bus 807#PC#5#FR#683407#FT#1532#TO#682943#TT#1624#",
"kurztext": "Bus",
"mitteltext": "Bus 807",
"abfrageOrt": {
"name": "Schlachthof, Rothenburg ob der Tauber",
"locationId": "A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@",
"evaNr": "680433"
},
"richtung": "Bahnhof, Dombühl",
"echtzeitNotizen": [],
"abgangsDatum": "2024-12-29T15:33:00+01:00",
"produktGattung": "BUS"
},
{
"zuglaufId": "2|#VN#1#ST#1734722398#PI#1#ZI#864022#TA#1#DA#291224#1S#677019#1T#1458#LS#683407#LT#1548#PU#81#RT#1#CA#Bus#ZE#817#ZB#Bus 817#PC#5#FR#677019#FT#1458#TO#683407#TT#1548#",
"kurztext": "Bus",
"mitteltext": "Bus 817",
"abfrageOrt": {
"name": "Schlachthof, Rothenburg ob der Tauber",
"locationId": "A=1@O=Schlachthof, Rothenburg ob der Tauber@X=10189255@Y=49373989@U=81@L=680433@",
"evaNr": "680433"
},
"richtung": "Bahnhof, Rothenburg ob der Tauber",
"echtzeitNotizen": [
{
"text": "Halt entfällt"
}
],
"abgangsDatum": "2024-12-29T15:47:00+01:00",
"produktGattung": "BUS"
}
]
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,124 @@
{"haltName":"Stuttgart Hbf","produktGattungen":[{"produktGattung":"HOCHGESCHWINDIGKEITSZUEGE","produkte":[{"name":"ICE"},{"name":"RJ"},{"name":"RJX"},{"name":"TGV"}]},{"produktGattung":"INTERCITYUNDEUROCITYZUEGE","produkte":[{"name":"EC"},{"name":"IC"},{"name":"NJ"}]},{"produktGattung":"INTERREGIOUNDSCHNELLZUEGE","produkte":[{"name":"BUS"},{"name":"Bus"},{"name":"D"},{"name":"DBK"},{"name":"EN"},{"name":"FLX"},{"name":"WB"}]},{"produktGattung":"NAHVERKEHRSONSTIGEZUEGE","produkte":[{"name":"GA"},{"name":"IRE"},{"name":"MEX"},{"name":"RB"},{"name":"RE"},{"name":"Bus EV"},{"name":"BusMEX90"}]},{"produktGattung":"SBAHNEN","produkte":[{"name":"S 1"},{"name":"S 2"}]},{"produktGattung":"BUSSE","produkte":[{"name":"Bus 40"},{"name":"Bus 42"},{"name":"BusMEX90"}]},{"produktGattung":"STRASSENBAHN","produkte":[{"name":"STB U1"},{"name":"STB U5"}]}]} {
"haltName": "Stuttgart Hbf",
"produktGattungen": [
{
"produktGattung": "HOCHGESCHWINDIGKEITSZUEGE",
"produkte": [
{
"name": "ICE"
},
{
"name": "RJ"
},
{
"name": "RJX"
},
{
"name": "TGV"
}
]
},
{
"produktGattung": "INTERCITYUNDEUROCITYZUEGE",
"produkte": [
{
"name": "EC"
},
{
"name": "IC"
},
{
"name": "NJ"
}
]
},
{
"produktGattung": "INTERREGIOUNDSCHNELLZUEGE",
"produkte": [
{
"name": "BUS"
},
{
"name": "Bus"
},
{
"name": "D"
},
{
"name": "DBK"
},
{
"name": "EN"
},
{
"name": "FLX"
},
{
"name": "WB"
}
]
},
{
"produktGattung": "NAHVERKEHRSONSTIGEZUEGE",
"produkte": [
{
"name": "GA"
},
{
"name": "IRE"
},
{
"name": "MEX"
},
{
"name": "RB"
},
{
"name": "RE"
},
{
"name": "Bus EV"
},
{
"name": "BusMEX90"
}
]
},
{
"produktGattung": "SBAHNEN",
"produkte": [
{
"name": "S 1"
},
{
"name": "S 2"
}
]
},
{
"produktGattung": "BUSSE",
"produkte": [
{
"name": "Bus 40"
},
{
"name": "Bus 42"
},
{
"name": "BusMEX90"
}
]
},
{
"produktGattung": "STRASSENBAHN",
"produkte": [
{
"name": "STB U1"
},
{
"name": "STB U5"
}
]
}
]
}

File diff suppressed because one or more lines are too long