From a0a4064bf0d6523b9fdf08c0ff7ba431127578bd Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 29 Dec 2021 21:23:28 +0100 Subject: [PATCH] =?UTF-8?q?trip/tripsByName:=20realtimeDataFrom=20->=20sep?= =?UTF-8?q?arate=20realtimeDataUpdatedAt=20field=20=F0=9F=92=A5=E2=9C=85?= =?UTF-8?q?=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/trip.md | 11 ++++++++--- docs/trips-by-name.md | 9 +++++++-- index.js | 20 ++++++++++++++++---- parse/trip.js | 7 +------ test/e2e/bvg.js | 5 +++-- test/e2e/cfl.js | 5 +++-- test/e2e/cmta.js | 5 +++-- test/e2e/db-busradar-nrw.js | 5 +++-- test/e2e/db.js | 7 ++++--- test/e2e/hvv.js | 5 +++-- test/e2e/insa.js | 5 +++-- test/e2e/invg.js | 5 +++-- test/e2e/lib/departures-in-direction.js | 2 +- test/e2e/lib/validators.js | 22 ++++++++++++++++++++++ test/e2e/mobil-nrw.js | 5 +++-- test/e2e/mobiliteit-lu.js | 5 +++-- test/e2e/nahsh.js | 5 +++-- test/e2e/nvv.js | 5 +++-- test/e2e/oebb.js | 5 +++-- test/e2e/pkp.js | 5 +++-- test/e2e/rejseplanen.js | 5 +++-- test/e2e/rmv.js | 5 +++-- test/e2e/saarfahrplan.js | 5 +++-- test/e2e/sbahn-muenchen.js | 5 +++-- test/e2e/sncb.js | 5 +++-- test/e2e/svv.js | 5 +++-- test/e2e/vbb.js | 11 ++++++----- test/e2e/vbn.js | 5 +++-- test/e2e/vrn.js | 5 +++-- test/e2e/vsn.js | 5 +++-- test/e2e/zvv.js | 5 +++-- test/fixtures/bvg-trip-with-occupancy.js | 2 -- test/fixtures/oebb-trip.js | 1 - test/fixtures/rejseplanen-trip.js | 1 - test/fixtures/vbb-on-demand-trip.js | 1 - 35 files changed, 134 insertions(+), 75 deletions(-) diff --git a/docs/trip.md b/docs/trip.md index 75bcb3fd..ccb56a5b 100644 --- a/docs/trip.md +++ b/docs/trip.md @@ -44,12 +44,17 @@ const vbbProfile = require('hafas-client/p/vbb') const client = createClient(vbbProfile) -console.log(await client.trip('1|31431|28|86|17122017', 'S9', { +const { + trip, + realtimeDataUpdatedAt, +} = await client.trip('1|31431|28|86|17122017', 'S9', { when: 1513534689273, -})) +}) ``` -The result looked like this: +`realtimeDataUpdatedAt` is a UNIX timestamp reflecting the latest moment when (at least some of) the response's realtime data have been updated. + +When running the code above, `trip` looked like this: ```js { diff --git a/docs/trips-by-name.md b/docs/trips-by-name.md index 09eb69e2..40ed61ab 100644 --- a/docs/trips-by-name.md +++ b/docs/trips-by-name.md @@ -12,7 +12,10 @@ const vbbProfile = require('hafas-client/p/vbb') const client = createClient(vbbProfile, 'my-awesome-program') -await client.tripsByName('S1') +const { + trips, + realtimeDataUpdatedAt, +} = await client.tripsByName('S1') ``` With `opt`, you can override the default options, which look like this: @@ -42,7 +45,9 @@ With `opt`, you can override the default options, which look like this: } ``` -The result may look like this: +`realtimeDataUpdatedAt` is a UNIX timestamp reflecting the latest moment when (at least some of) the response's realtime data have been updated. + +`trips` may look like this: ```js [ diff --git a/index.js b/index.js index 010cbaad..01e16f1d 100644 --- a/index.js +++ b/index.js @@ -495,8 +495,14 @@ const createClient = (profile, userAgent, opt = {}) => { const {res, common} = await profile.request({profile, opt}, userAgent, req) const ctx = {profile, opt, common, res} - // todo [breaking]: return object with realtimeDataUpdatedAt - return profile.parseTrip(ctx, res.journey) + const trip = profile.parseTrip(ctx, res.journey) + + return { + trip, + realtimeDataUpdatedAt: res.planrtTS && res.planrtTS !== '0' + ? parseInt(res.planrtTS) + : null, + } } // todo [breaking]: rename to trips()? @@ -576,8 +582,14 @@ const createClient = (profile, userAgent, opt = {}) => { // todo [breaking]: catch `NO_MATCH` errors, return [] const ctx = {profile, opt, common, res} - // todo [breaking]: return object with realtimeDataUpdatedAt - return res.jnyL.map(t => profile.parseTrip(ctx, t)) + const trips = res.jnyL.map(t => profile.parseTrip(ctx, t)) + + return { + trips, + realtimeDataUpdatedAt: res.planrtTS && res.planrtTS !== '0' + ? parseInt(res.planrtTS) + : null, + } } const radar = async ({north, west, south, east}, opt) => { diff --git a/parse/trip.js b/parse/trip.js index 797ed06a..ca5936a1 100644 --- a/parse/trip.js +++ b/parse/trip.js @@ -5,7 +5,7 @@ const maxBy = require('lodash/maxBy') const last = require('lodash/last') const parseTrip = (ctx, t) => { // t = raw trip - const {profile, opt, res} = ctx + const {profile, opt} = ctx // pretend the trip is a leg in a journey const fakeLeg = { @@ -43,11 +43,6 @@ const parseTrip = (ctx, t) => { // t = raw trip trip.scheduledDays = profile.parseScheduledDays(ctx, sDays) } - if (res.planrtTS) { - // todo [breaking]: remove here - trip.realtimeDataUpdatedAt = parseInt(res.planrtTS) - } - return trip } diff --git a/test/e2e/bvg.js b/test/e2e/bvg.js index 7a9dbc0c..ae1cb7bd 100644 --- a/test/e2e/bvg.js +++ b/test/e2e/bvg.js @@ -225,9 +225,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/cfl.js b/test/e2e/cfl.js index 6f39194a..d08d0567 100644 --- a/test/e2e/cfl.js +++ b/test/e2e/cfl.js @@ -176,9 +176,10 @@ tap.test('trip', async (t) => { const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/cmta.js b/test/e2e/cmta.js index d1c765c1..8fe383fb 100644 --- a/test/e2e/cmta.js +++ b/test/e2e/cmta.js @@ -155,9 +155,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/db-busradar-nrw.js b/test/e2e/db-busradar-nrw.js index 96f99e2e..36ae6374 100644 --- a/test/e2e/db-busradar-nrw.js +++ b/test/e2e/db-busradar-nrw.js @@ -55,9 +55,10 @@ tap.test('trip details', async (t) => { const p = res.departures[0] || {} t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/db.js b/test/e2e/db.js index b189f192..7625497f 100644 --- a/test/e2e/db.js +++ b/test/e2e/db.js @@ -11,7 +11,7 @@ const createClient = require('../..') const dbProfile = require('../../p/db') const products = require('../../p/db/products') const { - station: createValidateStation, + station: createValidateStation, trip: createValidateTrip } = require('./lib/validators') const createValidate = require('./lib/validate-fptf-with') @@ -314,7 +314,8 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) + + const tripRes = await client.trip(p.tripId, p.line.name, {when}) const validateTrip = createValidateTrip(cfg) const validate = createValidate(cfg, { @@ -324,7 +325,7 @@ tap.test('trip details', async (t) => { validateTrip(validate, trip, name) } }) - validate(t, trip, 'trip', 'trip') + validate(t, tripRes, 'tripResult', 'tripRes') t.end() }) diff --git a/test/e2e/hvv.js b/test/e2e/hvv.js index f82565d2..02a2fcef 100644 --- a/test/e2e/hvv.js +++ b/test/e2e/hvv.js @@ -144,9 +144,10 @@ tap.skip('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/insa.js b/test/e2e/insa.js index 0a423bcf..a2046320 100644 --- a/test/e2e/insa.js +++ b/test/e2e/insa.js @@ -182,9 +182,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/invg.js b/test/e2e/invg.js index aa03bf1f..16c63bb4 100644 --- a/test/e2e/invg.js +++ b/test/e2e/invg.js @@ -167,9 +167,10 @@ tap.test('trip details', async (t) => { const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/lib/departures-in-direction.js b/test/e2e/lib/departures-in-direction.js index e925c53e..8446219a 100644 --- a/test/e2e/lib/departures-in-direction.js +++ b/test/e2e/lib/departures-in-direction.js @@ -24,7 +24,7 @@ const testDeparturesInDirection = async (cfg) => { const name = `deps[${i}]` const line = dep.line && dep.line.name - const trip = await fetchTrip(dep.tripId, line, { + const {trip} = await fetchTrip(dep.tripId, line, { when, stopovers: true }) t.ok(trip.stopovers.some(st => ( diff --git a/test/e2e/lib/validators.js b/test/e2e/lib/validators.js index a5f8ff1f..16c82ec9 100644 --- a/test/e2e/lib/validators.js +++ b/test/e2e/lib/validators.js @@ -448,6 +448,26 @@ const validateTrip = (val, trip, name = 'trip') => { val.journeyLeg(val, withFakeTripId, name) } +const validateTripResult = (val, res, name = 'tripResult') => { + a.ok(isObj(res), name + ' must be an object') + + val.trip(val, res.trip, name + '.trip') + + val.realtimeDataUpdatedAt(val, res.realtimeDataUpdatedAt, name + '.realtimeDataUpdatedAt') +} + +const validateTripsByNameResult = (val, res, name = 'tripsByNameResult') => { + a.ok(isObj(res), name + ' must be an object') + + a.ok(Array.isArray(res.trips), name + '.trips must be an array') + a.ok(res.trips.length > 0, name + '.trips must not be empty') + for (let i = 0; i < res.trips.length; i++) { + val.trip(val, res.trips[i], `${name}.trips[${i}]`) + } + + val.realtimeDataUpdatedAt(val, res.realtimeDataUpdatedAt, name + '.realtimeDataUpdatedAt') +} + const createValidateArrivalOrDeparture = (type, cfg) => { if (type !== 'arrival' && type !== 'departure') throw new Error('invalid type') @@ -631,6 +651,8 @@ module.exports = { journeysResult: () => validateJourneysResult, refreshJourneyResult: () => validateRefreshJourneyResult, trip: () => validateTrip, + tripResult: () => validateTripResult, + tripsByNameResult: () => validateTripsByNameResult, arrival: createValidateArrival, departure: createValidateDeparture, arrivals: createValidateArrivals, diff --git a/test/e2e/mobil-nrw.js b/test/e2e/mobil-nrw.js index b9526f81..087dfcc4 100644 --- a/test/e2e/mobil-nrw.js +++ b/test/e2e/mobil-nrw.js @@ -142,9 +142,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/mobiliteit-lu.js b/test/e2e/mobiliteit-lu.js index e118acf4..b0260d16 100644 --- a/test/e2e/mobiliteit-lu.js +++ b/test/e2e/mobiliteit-lu.js @@ -180,9 +180,10 @@ tap.test('trip', async (t) => { const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/nahsh.js b/test/e2e/nahsh.js index 49aa3505..557ee91a 100644 --- a/test/e2e/nahsh.js +++ b/test/e2e/nahsh.js @@ -217,9 +217,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/nvv.js b/test/e2e/nvv.js index b5107009..0432931a 100644 --- a/test/e2e/nvv.js +++ b/test/e2e/nvv.js @@ -164,9 +164,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/oebb.js b/test/e2e/oebb.js index 27e9ce4c..c93cba87 100644 --- a/test/e2e/oebb.js +++ b/test/e2e/oebb.js @@ -237,9 +237,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/pkp.js b/test/e2e/pkp.js index 94204e50..739d207f 100644 --- a/test/e2e/pkp.js +++ b/test/e2e/pkp.js @@ -99,9 +99,10 @@ tap.skip('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, { when }) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/rejseplanen.js b/test/e2e/rejseplanen.js index 8de32ea4..17d78e14 100644 --- a/test/e2e/rejseplanen.js +++ b/test/e2e/rejseplanen.js @@ -111,9 +111,10 @@ tap.test('trip', async (t) => { const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/rmv.js b/test/e2e/rmv.js index 214f97d9..41237c66 100644 --- a/test/e2e/rmv.js +++ b/test/e2e/rmv.js @@ -59,9 +59,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/saarfahrplan.js b/test/e2e/saarfahrplan.js index 3dfe8428..adbf345b 100644 --- a/test/e2e/saarfahrplan.js +++ b/test/e2e/saarfahrplan.js @@ -165,9 +165,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, { when }) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, { when }) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/sbahn-muenchen.js b/test/e2e/sbahn-muenchen.js index ee152b0e..4f1c9d8f 100644 --- a/test/e2e/sbahn-muenchen.js +++ b/test/e2e/sbahn-muenchen.js @@ -170,9 +170,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/sncb.js b/test/e2e/sncb.js index bdde56ee..fc3be17f 100644 --- a/test/e2e/sncb.js +++ b/test/e2e/sncb.js @@ -64,9 +64,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/svv.js b/test/e2e/svv.js index f0b6a567..c2fedc83 100644 --- a/test/e2e/svv.js +++ b/test/e2e/svv.js @@ -66,9 +66,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/vbb.js b/test/e2e/vbb.js index 1d2889bf..aba36f38 100644 --- a/test/e2e/vbb.js +++ b/test/e2e/vbb.js @@ -177,9 +177,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) @@ -187,7 +188,7 @@ tap.test('trip details', async (t) => { // around `when`, as expected by `assertValidWhen`, as called by `validate`. // todo: allow turning this off? tap.skip('trips', async (t) => { - const r1 = await client.tripsByName('S1') + const {trips: r1} = await client.tripsByName('S1') t.ok(Array.isArray(r1)) t.ok(r1.length > 0) t.ok(r1.every(t => t.line.name.trim() === 'S1')) @@ -195,7 +196,7 @@ tap.skip('trips', async (t) => { validate(t, r1[i], 'trip', `r1[${i}]`) } - const r2 = await client.tripsByName('S1', { + const {trips: r2} = await client.tripsByName('S1', { onlyCurrentlyRunning: false, }) t.ok(Array.isArray(r2)) @@ -205,7 +206,7 @@ tap.skip('trips', async (t) => { validate(t, r2[i], 'trip', `r2[${i}]`) } - const r3 = await client.tripsByName('*', { + const {trips: r3} = await client.tripsByName('*', { onlyCurrentlyRunning: false, }) t.ok(Array.isArray(r3)) diff --git a/test/e2e/vbn.js b/test/e2e/vbn.js index 43589871..515d7841 100644 --- a/test/e2e/vbn.js +++ b/test/e2e/vbn.js @@ -59,9 +59,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/vrn.js b/test/e2e/vrn.js index 6908fcf3..b9a8a63e 100644 --- a/test/e2e/vrn.js +++ b/test/e2e/vrn.js @@ -138,9 +138,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/vsn.js b/test/e2e/vsn.js index 91285afe..ec528627 100644 --- a/test/e2e/vsn.js +++ b/test/e2e/vsn.js @@ -94,9 +94,10 @@ tap.test('trip', async (t) => { const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/e2e/zvv.js b/test/e2e/zvv.js index 96336594..e1701808 100644 --- a/test/e2e/zvv.js +++ b/test/e2e/zvv.js @@ -71,9 +71,10 @@ tap.test('trip details', async (t) => { const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') - const trip = await client.trip(p.tripId, p.line.name, {when}) - validate(t, trip, 'trip', 'trip') + const tripRes = await client.trip(p.tripId, p.line.name, {when}) + + validate(t, tripRes, 'tripResult', 'res') t.end() }) diff --git a/test/fixtures/bvg-trip-with-occupancy.js b/test/fixtures/bvg-trip-with-occupancy.js index f40de73d..873727f8 100644 --- a/test/fixtures/bvg-trip-with-occupancy.js +++ b/test/fixtures/bvg-trip-with-occupancy.js @@ -99,8 +99,6 @@ module.exports = { '2021-12-16': false, }, - realtimeDataUpdatedAt: 1635406146, - origin: { type: 'stop', id: '900009102', diff --git a/test/fixtures/oebb-trip.js b/test/fixtures/oebb-trip.js index 4e781201..480d7c47 100644 --- a/test/fixtures/oebb-trip.js +++ b/test/fixtures/oebb-trip.js @@ -100,7 +100,6 @@ module.exports = { id: '2|#VN#0#ST#1591790769#PI#0#ZI#398470#TA#0#DA#110620#1S#8100353#1T#1633#LS#8100002#LT#1948#PU#81#RT#1#CA#RJ#ZE#742#ZB#RJ 742 #', origin: wienFlughafen, destination: salzburgHbf, - realtimeDataUpdatedAt: 1591881826, arrival: '2020-06-11T19:48:00+02:00', plannedArrival: '2020-06-11T19:48:00+02:00', arrivalDelay: null, diff --git a/test/fixtures/rejseplanen-trip.js b/test/fixtures/rejseplanen-trip.js index 233330ff..acf7610c 100644 --- a/test/fixtures/rejseplanen-trip.js +++ b/test/fixtures/rejseplanen-trip.js @@ -21,7 +21,6 @@ module.exports = { product: 'national-train', operator: { type: 'operator', id: 'dsb', name: 'DSB' }, }, - realtimeDataUpdatedAt: 1634050700, origin: { type: 'stop', diff --git a/test/fixtures/vbb-on-demand-trip.js b/test/fixtures/vbb-on-demand-trip.js index 98581b36..377978f8 100644 --- a/test/fixtures/vbb-on-demand-trip.js +++ b/test/fixtures/vbb-on-demand-trip.js @@ -20,7 +20,6 @@ module.exports = { }, }, reachable: true, - realtimeDataUpdatedAt: 1635084435, origin: {}, departure: null,