-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boards: correctly handle missing rt info
- Loading branch information
1 parent
e18ac3f
commit 5bb4e66
Showing
6 changed files
with
161 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// todo: use import assertions once they're supported by Node.js & ESLint | ||
// https://github.com/tc39/proposal-import-assertions | ||
import {createRequire} from 'module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
import tap from 'tap'; | ||
|
||
import {createClient} from '../index.js'; | ||
import {profile as rawProfile} from '../p/db/index.js'; | ||
const res = require('./fixtures/db-departures-regio-guide.json'); | ||
import {dbDepartures as expected} from './fixtures/db-departures-regio-guide.js'; | ||
|
||
const client = createClient(rawProfile, 'public-transport/hafas-client:test'); | ||
const {profile} = client; | ||
|
||
const opt = { | ||
direction: null, | ||
duration: 10, | ||
linesOfStops: true, | ||
remarks: true, | ||
stopovers: true, | ||
includeRelatedStations: true, | ||
when: '2019-08-19T20:30:00+02:00', | ||
products: {}, | ||
}; | ||
|
||
tap.test('parses a regio-guide departure correctly', (t) => { | ||
const ctx = {profile, opt, common: null, res}; | ||
const departures = res.items.map(d => profile.parseDeparture(ctx, d)); | ||
|
||
t.same(departures, expected); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
const dbDepartures = [ | ||
{ | ||
tripId: '20241212-d1494ce6-1a01-38de-bf84-c0bceb12f503', | ||
stop: { | ||
type: 'stop', | ||
id: '8000365', | ||
name: 'Dombühl', | ||
location: null, | ||
}, | ||
when: '2024-12-12T12:34:00+01:00', | ||
plannedWhen: '2024-12-12T12:34:00+01:00', | ||
delay: 0, | ||
platform: '3', | ||
plannedPlatform: '3', | ||
direction: 'Nürnberg Hbf', | ||
provenance: null, | ||
line: { | ||
type: 'line', | ||
id: '88617', | ||
fahrtNr: '88617', | ||
name: 'RE 90', | ||
public: true, | ||
productName: 'RE', | ||
mode: 'train', | ||
product: 'regional', | ||
operator: null, | ||
}, | ||
remarks: [], | ||
origin: null, | ||
destination: { | ||
type: 'stop', | ||
id: '8000284', | ||
name: 'Nürnberg Hbf', | ||
location: null, | ||
}, | ||
}, | ||
{ | ||
tripId: '20241212-abd01ce0-cca3-3759-aa4b-410ea4d0a720', | ||
stop: { | ||
type: 'stop', | ||
id: '682943', | ||
name: 'Bahnhof, Dombühl', | ||
location: null, | ||
}, | ||
when: '2024-12-12T12:50:00+01:00', | ||
plannedWhen: '2024-12-12T12:50:00+01:00', | ||
delay: null, | ||
platform: null, | ||
plannedPlatform: null, | ||
direction: 'Gymnasium, Dinkelsbühl', | ||
provenance: null, | ||
line: { | ||
type: 'line', | ||
id: '2221', | ||
fahrtNr: '2221', | ||
name: 'Bus 813', | ||
public: true, | ||
productName: 'Bus', | ||
mode: 'bus', | ||
product: 'bus', | ||
operator: null, | ||
}, | ||
remarks: [], | ||
origin: null, | ||
destination: { | ||
type: 'stop', | ||
id: '676542', | ||
name: 'Gymnasium, Dinkelsbühl', | ||
location: null, | ||
}, | ||
}, | ||
{ | ||
tripId: '20241212-ab6272a5-4bf6-32c1-9344-b47e1fc49eeb', | ||
stop: { | ||
type: 'stop', | ||
id: '682943', | ||
name: 'Bahnhof, Dombühl', | ||
location: null, | ||
}, | ||
when: '2024-12-12T12:50:00+01:00', | ||
plannedWhen: '2024-12-12T12:50:00+01:00', | ||
delay: null, | ||
platform: null, | ||
plannedPlatform: null, | ||
direction: 'Bahnhof, Rothenburg ob der Tauber', | ||
provenance: null, | ||
line: { | ||
type: 'line', | ||
id: '2177', | ||
fahrtNr: '2177', | ||
name: 'Bus 807', | ||
public: true, | ||
productName: 'Bus', | ||
mode: 'bus', | ||
product: 'bus', | ||
operator: null, | ||
}, | ||
remarks: [], | ||
origin: null, | ||
destination: { | ||
type: 'stop', | ||
id: '683407', | ||
name: 'Bahnhof, Rothenburg ob der Tauber', | ||
location: null, | ||
}, | ||
}, | ||
]; | ||
|
||
export { | ||
dbDepartures, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"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"} |