reproduce #301: leg of an overnight journey completely within the next day

Co-Authored-By: Jannis R <mail@jannisr.de>
This commit is contained in:
Soeren Wegener 2023-11-13 15:37:49 +01:00 committed by Jannis R
parent eec06ba81a
commit 8a17401693
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 5360 additions and 0 deletions

View file

@ -0,0 +1,47 @@
// 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 res0 = require('./fixtures/db-journey-overnight-0.json')
const expected0 = require('./fixtures/db-journey-overnight-0.expected.json')
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
const {profile} = client
const baseOpt = {
results: null,
via: null,
stopovers: false,
transfers: -1,
transferTime: 0,
accessibility: 'none',
bike: false,
walkingSpeed: 'normal',
startWithWalking: true,
tickets: true,
polylines: true,
remarks: true,
scheduledDays: false,
products: {},
}
tap.test('parses a journey across day with correct timestamps', (t) => {
const opt = {
...baseOpt,
results: 4,
stopovers: true,
departure: '2023-11-13T22:00:00+01:00',
}
const common = profile.parseCommon({profile, opt, res: res0})
const ctx = {profile, opt, common, res: res0}
const journey = profile.parseJourney(ctx, res0.outConL[16])
t.same(journey, expected0)
t.end()
})

View file

@ -0,0 +1,198 @@
{
"type": "journey",
"legs": [
{
"origin": {
"type": "stop",
"id": "8000193",
"name": "Kassel Hbf",
"location": {
"type": "location",
"id": "8000193",
"latitude": 51.31832,
"longitude": 9.489903
},
"products": {
"nationalExpress": false,
"national": false,
"regionalExpress": false,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": false,
"tram": true,
"taxi": false
}
},
"destination": {
"type": "stop",
"id": "8003200",
"name": "Kassel-Wilhelmshöhe",
"location": {
"type": "location",
"id": "8003200",
"latitude": 51.312998,
"longitude": 9.446845
},
"products": {
"nationalExpress": true,
"national": true,
"regionalExpress": true,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": false,
"tram": true,
"taxi": false
}
},
"departure": "2023-11-13T22:14:00+01:00",
"plannedDeparture": "2023-11-13T22:14:00+01:00",
"departureDelay": null,
"arrival": "2023-11-13T22:21:00+01:00",
"plannedArrival": "2023-11-13T22:21:00+01:00",
"arrivalDelay": null,
"public": true,
"walking": true,
"distance": null,
"transfer": true
},
{
"origin": {
"type": "stop",
"id": "8003200",
"name": "Kassel-Wilhelmshöhe",
"location": {
"type": "location",
"id": "8003200",
"latitude": 51.312998,
"longitude": 9.446845
},
"products": {
"nationalExpress": true,
"national": true,
"regionalExpress": true,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": false,
"tram": true,
"taxi": false
}
},
"destination": {
"type": "stop",
"id": "8000147",
"name": "Hamburg-Harburg",
"location": {
"type": "location",
"id": "8000147",
"latitude": 0,
"longitude": 0
},
"products": {
"nationalExpress": true,
"national": true,
"regionalExpress": true,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": false,
"tram": false,
"taxi": false
}
},
"departure": "2023-11-13T22:21:00+01:00",
"plannedDeparture": "2023-11-13T22:21:00+01:00",
"departureDelay": null,
"arrival": "2023-11-14T01:22:00+01:00",
"plannedArrival": "2023-11-14T01:22:00+01:00",
"arrivalDelay": null,
"reachable": true,
"tripId": "1|202739|0|80|-1",
"line": {
"type": "line",
"id": "ice-592",
"fahrtNr": null,
"name": "ICE 592",
"public": true,
"productName": "ICE"
},
"direction": null,
"arrivalPlatform": null,
"plannedArrivalPlatform": null,
"arrivalPrognosisType": null,
"departurePlatform": "1",
"plannedDeparturePlatform": "1",
"departurePrognosisType": null
},
{
"origin": {
"type": "stop",
"id": "8000147",
"name": "Hamburg-Harburg",
"location": {
"type": "location",
"id": "8000147",
"latitude": 0,
"longitude": 0
},
"products": {
"nationalExpress": true,
"national": true,
"regionalExpress": true,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": false,
"tram": false,
"taxi": false
}
},
"destination": {
"type": "stop",
"id": "8002549",
"name": "Hamburg Hbf",
"location": {
"type": "location",
"id": "8002549",
"latitude": 0,
"longitude": 0
},
"products": {
"nationalExpress": true,
"national": true,
"regionalExpress": true,
"regional": true,
"suburban": true,
"bus": true,
"ferry": false,
"subway": true,
"tram": false,
"taxi": false
}
},
"departure": "2023-11-14T01:22:00+01:00",
"plannedDeparture": "2023-11-14T01:22:00+01:00",
"departureDelay": null,
"arrival": "2023-11-14T01:42:00+01:00",
"plannedArrival": "2023-11-14T01:42:00+01:00",
"arrivalDelay": null,
"public": true,
"walking": true,
"distance": null,
"transfer": true
}
],
"refreshToken": "D$A=1@O=Kassel Hbf@L=8000193@a=0@$A=1@O=Kassel-Wilhelmshöhe@L=8003200@a=0@$202311132214$202311132221$$$1$$$$$$§T$A=1@O=Kassel-Wilhelmshöhe@L=8003200@a=0@$A=1@O=Hamburg-Harburg@L=8000147@a=0@$202311132221$202311140122$ICE 592$$1$$$$$$§D$A=1@O=Hamburg-Harburg@L=8000147@a=0@$A=1@O=Hamburg Hbf@L=8002549@a=0@$202311140122$202311140142$$$1$$$$$$",
"price": {
"amount": 55.9,
"currency": "EUR",
"hint": null
}
}

5115
test/fixtures/db-journey-overnight-0.json vendored Normal file

File diff suppressed because it is too large Load diff