diff --git a/test/db.js b/test/db.js index 020ae236..53b29e34 100644 --- a/test/db.js +++ b/test/db.js @@ -109,29 +109,9 @@ test('Berlin Jungfernheide to München Hbf', co(function* (t) { for (let journey of journeys) { t.equal(journey.type, 'journey') - assertValidStation(t, journey.origin) - assertValidStationProducts(t, journey.origin.products) - if (!(yield findStation(journey.origin.id))) { - console.error('unknown station', journey.origin.id, journey.origin.name) - } - if (journey.origin.products) { - assertValidProducts(t, journey.origin.products) - } - assertValidWhen(t, journey.departure, when) - - assertValidStation(t, journey.destination) - assertValidStationProducts(t, journey.origin.products) - if (!(yield findStation(journey.origin.id))) { - console.error('unknown station', journey.destination.id, journey.destination.name) - } - if (journey.destination.products) { - assertValidProducts(t, journey.destination.products) - } - assertValidWhen(t, journey.arrival, when) - t.ok(Array.isArray(journey.legs)) t.ok(journey.legs.length > 0, 'no legs') - const leg = journey.legs[0] + const leg = journey.legs[0] // todo: all legs assertValidStation(t, leg.origin) assertValidStationProducts(t, leg.origin.products) @@ -284,7 +264,7 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) { let earliestDep = Infinity, latestDep = -Infinity for (let j of model) { - const dep = +new Date(j.departure) + const dep = +new Date(j.legs[0].departure) if (dep < earliestDep) earliestDep = dep else if (dep > latestDep) latestDep = dep } @@ -295,7 +275,7 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) { earlierThan: model.earlierRef }) for (let j of earlier) { - t.ok(new Date(j.departure) < earliestDep) + t.ok(new Date(j.legs[0].departure) < earliestDep) } const later = yield client.journeys(jungfernh, münchenHbf, { @@ -304,7 +284,7 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) { laterThan: model.laterRef }) for (let j of later) { - t.ok(new Date(j.departure) > latestDep) + t.ok(new Date(j.legs[0].departure) > latestDep) } t.end() diff --git a/test/insa.js b/test/insa.js index 3afa29ee..3830c809 100644 --- a/test/insa.js +++ b/test/insa.js @@ -77,23 +77,9 @@ test('Magdeburg Hbf to Magdeburg-Buckau', co(function*(t) { t.ok(Array.isArray(journeys)) t.ok(journeys.length > 0, 'no journeys') for (let journey of journeys) { - assertValidStation(t, journey.origin) - assertValidStationProducts(t, journey.origin.products) - if (journey.origin.products) { - assertValidProducts(t, journey.origin.products) - } - assertValidWhen(t, journey.departure, when) - - assertValidStation(t, journey.destination) - assertValidStationProducts(t, journey.origin.products) - if (journey.destination.products) { - assertValidProducts(t, journey.destination.products) - } - assertValidWhen(t, journey.arrival, when) - t.ok(Array.isArray(journey.legs)) t.ok(journey.legs.length > 0, 'no legs') - const leg = journey.legs[0] + const leg = journey.legs[0] // todo: all legs assertValidStation(t, leg.origin) assertValidStationProducts(t, leg.origin.products) diff --git a/test/nahsh.js b/test/nahsh.js index 0b8b2b04..c125274b 100644 --- a/test/nahsh.js +++ b/test/nahsh.js @@ -12,7 +12,7 @@ const validateLineWithoutMode = require('./validate-line-without-mode') const co = require('./co') const createClient = require('..') const nahshProfile = require('../p/nahsh') -const {allProducts} = require('../p/nahsh/products') +const allProducts = require('../p/nahsh/products') const { assertValidStation, assertValidPoi, @@ -108,31 +108,9 @@ test('Kiel Hbf to Flensburg', co(function* (t) { for (let journey of journeys) { t.equal(journey.type, 'journey') - assertValidStation(t, journey.origin) - assertValidStationProducts(t, journey.origin.products) - // todo - // if (!(yield findStation(journey.origin.id))) { - // console.error('unknown station', journey.origin.id, journey.origin.name) - // } - if (journey.origin.products) { - assertValidProducts(t, journey.origin.products) - } - assertValidWhen(t, journey.departure, when) - - assertValidStation(t, journey.destination) - assertValidStationProducts(t, journey.origin.products) - // todo - // if (!(yield findStation(journey.origin.id))) { - // console.error('unknown station', journey.destination.id, journey.destination.name) - // } - if (journey.destination.products) { - assertValidProducts(t, journey.destination.products) - } - assertValidWhen(t, journey.arrival, when) - t.ok(Array.isArray(journey.legs)) t.ok(journey.legs.length > 0, 'no legs') - const leg = journey.legs[0] + const leg = journey.legs[0] // todo: all legs assertValidStation(t, leg.origin) assertValidStationProducts(t, leg.origin.products) @@ -279,7 +257,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) { let earliestDep = Infinity, latestDep = -Infinity for (let j of model) { - const dep = +new Date(j.departure) + const dep = +new Date(j.legs[0].departure) if (dep < earliestDep) earliestDep = dep else if (dep > latestDep) latestDep = dep } @@ -290,7 +268,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) { earlierThan: model.earlierRef }) for (let j of earlier) { - t.ok(new Date(j.departure) < earliestDep) + t.ok(new Date(j.legs[0].departure) < earliestDep) } const later = yield client.journeys(kielHbf, flensburg, { @@ -299,7 +277,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) { laterThan: model.laterRef }) for (let j of later) { - t.ok(new Date(j.departure) > latestDep) + t.ok(new Date(j.legs[0].departure) > latestDep) } t.end() diff --git a/test/oebb.js b/test/oebb.js index 319f79f6..feae6c65 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -128,31 +128,9 @@ test('Salzburg Hbf to Wien Westbahnhof', co(function* (t) { for (let journey of journeys) { t.equal(journey.type, 'journey') - assertValidStation(t, journey.origin) - assertValidStationProducts(t, journey.origin.products) - // todo - // if (!(yield findStation(journey.origin.id))) { - // console.error('unknown station', journey.origin.id, journey.origin.name) - // } - if (journey.origin.products) { - assertValidProducts(t, journey.origin.products) - } - assertValidWhen(t, journey.departure, when) - - assertValidStation(t, journey.destination) - assertValidStationProducts(t, journey.origin.products) - // todo - // if (!(yield findStation(journey.origin.id))) { - // console.error('unknown station', journey.destination.id, journey.destination.name) - // } - if (journey.destination.products) { - assertValidProducts(t, journey.destination.products) - } - assertValidWhen(t, journey.arrival, when) - t.ok(Array.isArray(journey.legs)) t.ok(journey.legs.length > 0, 'no legs') - const leg = journey.legs[0] + const leg = journey.legs[0] // todo: all legs assertValidStation(t, leg.origin) assertValidStationProducts(t, leg.origin.products) @@ -327,7 +305,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t let earliestDep = Infinity, latestDep = -Infinity for (let j of model) { - const dep = +new Date(j.departure) + const dep = +new Date(j.legs[0].departure) if (dep < earliestDep) earliestDep = dep else if (dep > latestDep) latestDep = dep } @@ -338,7 +316,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t earlierThan: model.earlierRef }) for (let j of earlier) { - t.ok(new Date(j.departure) < earliestDep) + t.ok(new Date(j.legs[0].departure) < earliestDep) } const later = yield client.journeys(salzburgHbf, wienWestbahnhof, { @@ -347,7 +325,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t laterThan: model.laterRef }) for (let j of later) { - t.ok(new Date(j.departure) > latestDep) + t.ok(new Date(j.legs[0].departure) > latestDep) } t.end() diff --git a/test/vbb.js b/test/vbb.js index f2fedf6a..c94dc9d5 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -69,20 +69,9 @@ test('journeys – station to station', co(function* (t) { for (let journey of journeys) { t.equal(journey.type, 'journey') - assertValidStation(t, journey.origin) - assertValidStationProducts(t, journey.origin.products) - t.ok(journey.origin.name.indexOf('(Berlin)') === -1) - t.strictEqual(journey.origin.id, spichernstr) - assertValidWhen(t, journey.departure, when) - - assertValidStation(t, journey.destination) - assertValidStationProducts(t, journey.destination.products) - t.strictEqual(journey.destination.id, amrumerStr) - assertValidWhen(t, journey.arrival, when) - t.ok(Array.isArray(journey.legs)) t.strictEqual(journey.legs.length, 1) - const leg = journey.legs[0] + const leg = journey.legs[0] // todo: all legs t.equal(typeof leg.id, 'string') t.ok(leg.id) @@ -192,7 +181,7 @@ test('earlier/later journeys', co(function* (t) { let earliestDep = Infinity, latestDep = -Infinity for (let j of model) { - const dep = +new Date(j.departure) + const dep = +new Date(j.legs[0].departure) if (dep < earliestDep) earliestDep = dep else if (dep > latestDep) latestDep = dep } @@ -203,7 +192,7 @@ test('earlier/later journeys', co(function* (t) { earlierThan: model.earlierRef }) for (let j of earlier) { - t.ok(new Date(j.departure) < earliestDep) + t.ok(new Date(j.legs[0].departure) < earliestDep) } const later = yield client.journeys(spichernstr, bismarckstr, { @@ -212,7 +201,7 @@ test('earlier/later journeys', co(function* (t) { laterThan: model.laterRef }) for (let j of later) { - t.ok(new Date(j.departure) > latestDep) + t.ok(new Date(j.legs[0].departure) > latestDep) } t.end()