mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
adapt tests to 0e80be0 ✅
This commit is contained in:
parent
005f3f8e4d
commit
4cba773eb0
5 changed files with 18 additions and 107 deletions
28
test/db.js
28
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()
|
||||
|
|
16
test/insa.js
16
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)
|
||||
|
|
|
@ -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()
|
||||
|
|
30
test/oebb.js
30
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()
|
||||
|
|
19
test/vbb.js
19
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()
|
||||
|
|
Loading…
Add table
Reference in a new issue