mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
rename journeyLeg() to trip() 💥, adapt tests
This commit is contained in:
parent
86fc27e340
commit
ab5ca3db8b
8 changed files with 32 additions and 27 deletions
|
@ -8,8 +8,8 @@ This version is not fully backwords-compatible. Check out [the migration guide](
|
||||||
|
|
||||||
- 0db84ce #61 parse remarks for stopovers and journey legs
|
- 0db84ce #61 parse remarks for stopovers and journey legs
|
||||||
- ac9819b `arrivals()` method – [docs](arrivals.md)
|
- ac9819b `arrivals()` method – [docs](arrivals.md)
|
||||||
- 21c273c `journeys()`/`journeyLeg()`: leg stopovers: parse & expose delays
|
- 21c273c `journeys()`/`trip()`: leg stopovers: parse & expose delays
|
||||||
- 021ae45 `journeys()`/`journeyLeg()`: leg stopovers: parse & expose platforms
|
- 021ae45 `journeys()`/`trip()`: leg stopovers: parse & expose platforms
|
||||||
- 84bce0c `arrivals()`/`departures()`: parse & expose platforms
|
- 84bce0c `arrivals()`/`departures()`: parse & expose platforms
|
||||||
- 85e0bdf `journeys()`: `startWithWalking` option with default `true`
|
- 85e0bdf `journeys()`: `startWithWalking` option with default `true`
|
||||||
- f6ae29c journey legs with `type: 'walking'` now have a `distance` in meters
|
- f6ae29c journey legs with `type: 'walking'` now have a `distance` in meters
|
||||||
|
@ -24,12 +24,13 @@ This version is not fully backwords-compatible. Check out [the migration guide](
|
||||||
- a356a26 throw if 0 products enabled
|
- a356a26 throw if 0 products enabled
|
||||||
- c82ad23 `journeys()`: `opt.when` → `opt.departure`/`opt.arrival`
|
- c82ad23 `journeys()`: `opt.when` → `opt.departure`/`opt.arrival`
|
||||||
- 665bed9 rename `location(id)` to `station(id)`
|
- 665bed9 rename `location(id)` to `station(id)`
|
||||||
- 6611f26 `journeys()`/`journeyLeg()`: `leg.passed` → `leg.stopovers`
|
- 6611f26 `journeys()`/`trip()`: `leg.passed` → `leg.stopovers`
|
||||||
- ebe4fa6 `journeys()`/`journeyLeg()`: `opt.passedStations` → `opt.stopovers`
|
- ebe4fa6 `journeys()`/`trip()`: `opt.passedStations` → `opt.stopovers`
|
||||||
- 3e672ee `journeys()`/`journeyLeg()`: `stopover.station` → `stopover.stop`
|
- 3e672ee `journeys()`/`trip()`: `stopover.station` → `stopover.stop`
|
||||||
- 2e6aefe journey leg, departure, movement: `journeyId` -> `tripId`
|
- 2e6aefe journey leg, departure, movement: `journeyId` -> `tripId`
|
||||||
- 8881d8a & b6fbaa5: change parsers signature to `parse…(profile, opt, data)`
|
- 8881d8a & b6fbaa5: change parsers signature to `parse…(profile, opt, data)`
|
||||||
- cabe5fa: option to parse & expose `station.lines`, default off
|
- cabe5fa: option to parse & expose `station.lines`, default off
|
||||||
|
- c8ff217 rename `journeyLeg()` to `trip()`
|
||||||
|
|
||||||
### bugfixes
|
### bugfixes
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
# Migrating to `hafas-client@3`
|
# Migrating to `hafas-client@3`
|
||||||
|
|
||||||
## If you use the `journeys()` or `journeyLeg()` methods…
|
## If you use the `journeyLeg()` method…
|
||||||
|
|
||||||
|
…change the `journeyLeg(id, lineName)` call to `trip(id, lineName)`. c8ff217
|
||||||
|
|
||||||
|
## If you use the `journeys()` or `trip()` methods…
|
||||||
|
|
||||||
- …instead of `journey.departure`, use `journey.legs[0].departure`. 005f3f8
|
- …instead of `journey.departure`, use `journey.legs[0].departure`. 005f3f8
|
||||||
- …instead of `journey.arrival`, use `journey.legs[last].arrival`. 005f3f8
|
- …instead of `journey.arrival`, use `journey.legs[last].arrival`. 005f3f8
|
||||||
|
@ -13,7 +17,7 @@
|
||||||
|
|
||||||
…use `opt.departure` instead. Use `opt.arrival` to get journeys arriving before the specified date+time. This replaces the `opt.when` & `opt.whenRepresents` options from `hafas-client@2`. c82ad23
|
…use `opt.departure` instead. Use `opt.arrival` to get journeys arriving before the specified date+time. This replaces the `opt.when` & `opt.whenRepresents` options from `hafas-client@2`. c82ad23
|
||||||
|
|
||||||
## If you use the `journeys()` and `opt.polylines` or `journeyLeg()` and `opt.polyline`…
|
## If you use the `journeys()` and `opt.polylines` or `trip()` and `opt.polyline`…
|
||||||
|
|
||||||
…`leg.polyline` will be [parsed for you now](https://github.com/public-transport/hafas-client/blob/f6c824eecb459181ea90ddf41bf1a1e8b64539ec/docs/journey-leg.md#polyline-option).
|
…`leg.polyline` will be [parsed for you now](https://github.com/public-transport/hafas-client/blob/f6c824eecb459181ea90ddf41bf1a1e8b64539ec/docs/journey-leg.md#polyline-option).
|
||||||
|
|
||||||
|
|
10
index.js
10
index.js
|
@ -315,9 +315,9 @@ const createClient = (profile, request = _request) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeyLeg = (ref, lineName, opt = {}) => {
|
const trip = (id, lineName, opt = {}) => {
|
||||||
if (!isNonEmptyString(ref)) {
|
if (!isNonEmptyString(id)) {
|
||||||
throw new Error('ref must be a non-empty string.')
|
throw new Error('id must be a non-empty string.')
|
||||||
}
|
}
|
||||||
if (!isNonEmptyString(lineName)) {
|
if (!isNonEmptyString(lineName)) {
|
||||||
throw new Error('lineName must be a non-empty string.')
|
throw new Error('lineName must be a non-empty string.')
|
||||||
|
@ -335,7 +335,7 @@ const createClient = (profile, request = _request) => {
|
||||||
meth: 'JourneyDetails',
|
meth: 'JourneyDetails',
|
||||||
req: {
|
req: {
|
||||||
// todo: getTrainComposition
|
// todo: getTrainComposition
|
||||||
jid: ref,
|
jid: id,
|
||||||
name: lineName,
|
name: lineName,
|
||||||
date: profile.formatDate(profile, opt.when),
|
date: profile.formatDate(profile, opt.when),
|
||||||
getPolyline: !!opt.polyline
|
getPolyline: !!opt.polyline
|
||||||
|
@ -413,7 +413,7 @@ const createClient = (profile, request = _request) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = {departures, arrivals, journeys, locations, station, nearby}
|
const client = {departures, arrivals, journeys, locations, station, nearby}
|
||||||
if (profile.journeyLeg) client.journeyLeg = journeyLeg
|
if (profile.journeyLeg) client.trip = trip
|
||||||
if (profile.radar) client.radar = radar
|
if (profile.radar) client.radar = radar
|
||||||
Object.defineProperty(client, 'profile', {value: profile})
|
Object.defineProperty(client, 'profile', {value: profile})
|
||||||
return client
|
return client
|
||||||
|
|
|
@ -189,7 +189,7 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('journey leg details', co(function* (t) {
|
test('trip details', co(function* (t) {
|
||||||
const journeys = yield client.journeys(berlinHbf, münchenHbf, {
|
const journeys = yield client.journeys(berlinHbf, münchenHbf, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
@ -197,7 +197,7 @@ test('journey leg details', co(function* (t) {
|
||||||
const p = journeys[0].legs[0]
|
const p = journeys[0].legs[0]
|
||||||
t.ok(p.id, 'precondition failed')
|
t.ok(p.id, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
const trip = yield client.trip(p.id, p.line.name, {when})
|
||||||
|
|
||||||
const validateJourneyLeg = createValidateJourneyLeg(cfg)
|
const validateJourneyLeg = createValidateJourneyLeg(cfg)
|
||||||
const validate = createValidate(cfg, {
|
const validate = createValidate(cfg, {
|
||||||
|
@ -206,7 +206,7 @@ test('journey leg details', co(function* (t) {
|
||||||
validateJourneyLeg(validate, leg, name)
|
validateJourneyLeg(validate, leg, name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
validate(t, leg, 'journeyLeg', 'leg')
|
validate(t, trip, 'journeyLeg', 'trip')
|
||||||
|
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -152,7 +152,7 @@ test('earlier/later journeys', co(function* (t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('journey leg details', co(function* (t) {
|
test('trip details', co(function* (t) {
|
||||||
const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
|
const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
@ -160,9 +160,9 @@ test('journey leg details', co(function* (t) {
|
||||||
const p = journeys[0].legs[0]
|
const p = journeys[0].legs[0]
|
||||||
t.ok(p.id, 'precondition failed')
|
t.ok(p.id, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
const trip = yield client.trip(p.id, p.line.name, {when})
|
||||||
|
|
||||||
validate(t, leg, 'journeyLeg', 'leg')
|
validate(t, trip, 'journeyLeg', 'trip')
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
|
||||||
// todo: with detour test
|
// todo: with detour test
|
||||||
// todo: without detour test
|
// todo: without detour test
|
||||||
|
|
||||||
test('journey leg details for Flensburg to Husum', co(function* (t) {
|
test('trip details', co(function* (t) {
|
||||||
const journeys = yield client.journeys(flensburg, husum, {
|
const journeys = yield client.journeys(flensburg, husum, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
@ -192,9 +192,9 @@ test('journey leg details for Flensburg to Husum', co(function* (t) {
|
||||||
const p = journeys[0].legs[0]
|
const p = journeys[0].legs[0]
|
||||||
t.ok(p.id, 'precondition failed')
|
t.ok(p.id, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
const trip = yield client.trip(p.id, p.line.name, {when})
|
||||||
|
|
||||||
validate(t, leg, 'journeyLeg', 'leg')
|
validate(t, trip, 'journeyLeg', 'trip')
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('leg details for Wien Westbahnhof to München Hbf', co(function* (t) {
|
test('trip details', co(function* (t) {
|
||||||
const journeys = yield client.journeys(wienWestbahnhof, muenchenHbf, {
|
const journeys = yield client.journeys(wienWestbahnhof, muenchenHbf, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
@ -217,9 +217,9 @@ test('leg details for Wien Westbahnhof to München Hbf', co(function* (t) {
|
||||||
const p = journeys[0].legs[0]
|
const p = journeys[0].legs[0]
|
||||||
t.ok(p.id, 'precondition failed')
|
t.ok(p.id, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
const trip = yield client.trip(p.id, p.line.name, {when})
|
||||||
|
|
||||||
validate(t, leg, 'journeyLeg', 'leg')
|
validate(t, trip, 'journeyLeg', 'trip')
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ test('earlier/later journeys', co(function* (t) {
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
test('journey leg details', co(function* (t) {
|
test('trip details', co(function* (t) {
|
||||||
const journeys = yield client.journeys(spichernstr, amrumerStr, {
|
const journeys = yield client.journeys(spichernstr, amrumerStr, {
|
||||||
results: 1, departure: when
|
results: 1, departure: when
|
||||||
})
|
})
|
||||||
|
@ -195,9 +195,9 @@ test('journey leg details', co(function* (t) {
|
||||||
const p = journeys[0].legs[0]
|
const p = journeys[0].legs[0]
|
||||||
t.ok(p.id, 'precondition failed')
|
t.ok(p.id, 'precondition failed')
|
||||||
t.ok(p.line.name, 'precondition failed')
|
t.ok(p.line.name, 'precondition failed')
|
||||||
const leg = yield client.journeyLeg(p.id, p.line.name, {when})
|
const trip = yield client.trip(p.id, p.line.name, {when})
|
||||||
|
|
||||||
validate(t, leg, 'journeyLeg', 'leg')
|
validate(t, trip, 'journeyLeg', 'trip')
|
||||||
t.end()
|
t.end()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue