adapt nah.sh radar test to #34

This commit is contained in:
Jannis R 2018-05-07 11:47:49 +02:00 committed by Jannis Redmann
parent 187d2ac04e
commit 7541bcae66

View file

@ -379,9 +379,41 @@ test('location', co(function* (t) {
t.end() t.end()
})) }))
// todo: see #34 test('radar Kiel', co(function* (t) {
test.skip('radar Kiel', co(function* (t) { const fakeStation = (s) => {
const vehicles = yield client.radar(54.4, 10.0, 54.2, 10.2, { const fake = Object.assign({
products: {
nationalExp: true,
national: false,
interregional: true,
regional: false,
suburban: true,
bus: false,
ferry: true,
subway: false,
tram: true,
onCall: false
}
}, s)
if (s.name === null) fake.name = 'foo'
return fake
}
const _assertValidStation = (t, s, coordsOptional = false) => {
assertValidStation(t, fakeStation(s), coordsOptional)
}
const _assertValidStopover = (t, s, coordsOptional = false) => {
const fake = Object.assign({}, s, {
station: fakeStation(s.station)
})
assertValidStopover(t, fake, coordsOptional)
}
const vehicles = yield client.radar({
north: 54.4,
west: 10.0,
south: 54.2,
east: 10.2
}, {
duration: 5 * 60, when duration: 5 * 60, when
}) })
@ -402,7 +434,7 @@ test.skip('radar Kiel', co(function* (t) {
t.ok(Array.isArray(v.nextStops)) t.ok(Array.isArray(v.nextStops))
for (let st of v.nextStops) { for (let st of v.nextStops) {
assertValidStopover(t, st, true) _assertValidStopover(t, st, true)
if (st.arrival) { if (st.arrival) {
t.equal(typeof st.arrival, 'string') t.equal(typeof st.arrival, 'string')
@ -419,10 +451,15 @@ test.skip('radar Kiel', co(function* (t) {
t.ok(Array.isArray(v.frames)) t.ok(Array.isArray(v.frames))
for (let f of v.frames) { for (let f of v.frames) {
assertValidStation(t, f.origin, true) // todo: see #34
assertValidStationProducts(t, f.origin.products) _assertValidStation(t, f.origin, true)
assertValidStation(t, f.destination, true) if (f.origin.products) {
assertValidStationProducts(t, f.destination.products) assertValidStationProducts(t, f.origin.products)
}
_assertValidStation(t, f.destination, true)
if (f.destination.products) {
assertValidStationProducts(t, f.destination.products)
}
t.equal(typeof f.t, 'number') t.equal(typeof f.t, 'number')
} }
} }