From ca6e5a0d5435505e502d51b55fbada589a7ba0e2 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sat, 17 Mar 2018 17:27:43 +0100 Subject: [PATCH] NAH.SH: remove unnecessary headers, skip radar test --- p/nahsh/index.js | 5 +-- test/nahsh.js | 100 +++++++++++++++++++++++------------------------ 2 files changed, 50 insertions(+), 55 deletions(-) diff --git a/p/nahsh/index.js b/p/nahsh/index.js index b8f7a5ef..9d94ac20 100644 --- a/p/nahsh/index.js +++ b/p/nahsh/index.js @@ -11,12 +11,9 @@ const products = require('./products') // todo: journey prices const transformReqBody = (body) => { - // todo: all headers necessary? body.client = { id: 'NAHSH', name: 'NAHSHPROD', - os: 'iOS', - type: 'IPH', v: '3000700' } body.ver = '1.16' @@ -144,7 +141,7 @@ const nahshProfile = { formatProducts, journeyLeg: true, - radar: false // todo: fix nameless station bug + radar: false // todo: see #34 } module.exports = nahshProfile diff --git a/test/nahsh.js b/test/nahsh.js index 2c99674c..0b8b2b04 100644 --- a/test/nahsh.js +++ b/test/nahsh.js @@ -401,54 +401,52 @@ test('location', co(function* (t) { t.end() })) -// todo: fix nameless station bug -// test('radar Kiel', co(function* (t) { -// const vehicles = yield client.radar(54.4, 10.0, 54.2, 10.2, { -// duration: 5 * 60, when -// }) -// -// t.ok(Array.isArray(vehicles)) -// t.ok(vehicles.length > 0) -// for (let v of vehicles) { -// -// // todo -// // t.ok(findStation(v.direction)) -// assertValidLine(t, v.line) -// -// t.equal(typeof v.location.latitude, 'number') -// t.ok(v.location.latitude <= 57, 'vehicle is too far away') -// t.ok(v.location.latitude >= 51, 'vehicle is too far away') -// t.equal(typeof v.location.longitude, 'number') -// t.ok(v.location.longitude >= 7, 'vehicle is too far away') -// t.ok(v.location.longitude <= 13, 'vehicle is too far away') -// -// t.ok(Array.isArray(v.nextStops)) -// for (let st of v.nextStops) { -// assertValidStopover(t, st, true) -// -// if (st.arrival) { -// t.equal(typeof st.arrival, 'string') -// const arr = +new Date(st.arrival) -// // note that this can be an ICE train -// t.ok(isRoughlyEqual(14 * hour, +when, arr)) -// } -// if (st.departure) { -// t.equal(typeof st.departure, 'string') -// const dep = +new Date(st.departure) -// t.ok(isRoughlyEqual(14 * hour, +when, dep)) -// } -// } -// -// t.ok(Array.isArray(v.frames)) -// for (let f of v.frames) { -// assertValidStation(t, f.origin, true) -// // can contain stations in germany which don't have a products property, would break -// // assertValidStationProducts(t, f.origin.products) -// assertValidStation(t, f.destination, true) -// // can contain stations in germany which don't have a products property, would break -// // assertValidStationProducts(t, f.destination.products) -// t.equal(typeof f.t, 'number') -// } -// } -// t.end() -// })) +// todo: see #34 +test.skip('radar Kiel', co(function* (t) { + const vehicles = yield client.radar(54.4, 10.0, 54.2, 10.2, { + duration: 5 * 60, when + }) + + t.ok(Array.isArray(vehicles)) + t.ok(vehicles.length > 0) + for (let v of vehicles) { + + // todo + // t.ok(findStation(v.direction)) + assertValidLine(t, v.line) + + t.equal(typeof v.location.latitude, 'number') + t.ok(v.location.latitude <= 57, 'vehicle is too far away') + t.ok(v.location.latitude >= 51, 'vehicle is too far away') + t.equal(typeof v.location.longitude, 'number') + t.ok(v.location.longitude >= 7, 'vehicle is too far away') + t.ok(v.location.longitude <= 13, 'vehicle is too far away') + + t.ok(Array.isArray(v.nextStops)) + for (let st of v.nextStops) { + assertValidStopover(t, st, true) + + if (st.arrival) { + t.equal(typeof st.arrival, 'string') + const arr = +new Date(st.arrival) + // note that this can be an ICE train + t.ok(isRoughlyEqual(14 * hour, +when, arr)) + } + if (st.departure) { + t.equal(typeof st.departure, 'string') + const dep = +new Date(st.departure) + t.ok(isRoughlyEqual(14 * hour, +when, dep)) + } + } + + t.ok(Array.isArray(v.frames)) + for (let f of v.frames) { + assertValidStation(t, f.origin, true) + assertValidStationProducts(t, f.origin.products) + assertValidStation(t, f.destination, true) + assertValidStationProducts(t, f.destination.products) + t.equal(typeof f.t, 'number') + } + } + t.end() +}))