From 0408f92257b1af4d432dc636a93aec4e7daac74e Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 23 Jan 2018 02:26:53 +0100 Subject: [PATCH] handle unhelpful VBB directions without failing :green_heart: see also #16 --- test/vbb.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/vbb.js b/test/vbb.js index 9be3e0b1..bb271361 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -49,7 +49,6 @@ const assertValidLine = (t, l) => { if (l.night !== null) t.equal(typeof l.night, 'boolean') } -// todo const findStation = (query) => stations(query, true, false)[0] const test = tapePromise(tape) @@ -97,7 +96,11 @@ test('journeys – station to station', co(function* (t) { assertValidWhen(t, leg.arrival, when) assertValidLine(t, leg.line) - t.ok(findStation(leg.direction)) + if (!findStation(leg.direction)) { + const err = new Error('unknown direction: ' + leg.direction) + err.stack = err.stack.split('\n').slice(0, 2).join('\n') + console.error(err) + } t.ok(leg.direction.indexOf('(Berlin)') === -1) t.ok(Array.isArray(leg.passed)) @@ -276,7 +279,11 @@ test('departures', co(function* (t) { t.strictEqual(dep.station.id, spichernstr) assertValidWhen(t, dep.when, when) - t.ok(findStation(dep.direction)) + if (!findStation(dep.direction)) { + const err = new Error('unknown direction: ' + dep.direction) + err.stack = err.stack.split('\n').slice(0, 2).join('\n') + console.error(err) + } assertValidLine(t, dep.line) } t.end() @@ -365,7 +372,11 @@ test('radar', co(function* (t) { t.ok(vehicles.length > 0) for (let v of vehicles) { - t.ok(findStation(v.direction)) + if (!findStation(v.direction)) { + const err = new Error('unknown direction: ' + v.direction) + err.stack = err.stack.split('\n').slice(0, 2).join('\n') + console.error(err) + } assertValidLine(t, v.line) t.equal(typeof v.location.latitude, 'number')