From b2a3ce4d667a6f4f5d759538fe879e3f686fa5d4 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 18 Aug 2020 02:19:32 +0200 Subject: [PATCH] =?UTF-8?q?E2E/integration=20tests:=20fix=20stopover=20&?= =?UTF-8?q?=20leg=20validation=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/lib/validators.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/e2e/lib/validators.js b/test/e2e/lib/validators.js index b4f5c4cc..4817ee25 100644 --- a/test/e2e/lib/validators.js +++ b/test/e2e/lib/validators.js @@ -123,10 +123,10 @@ const createValidateStopover = (cfg) => { val.date(val, s.plannedDeparture, name + '.plannedDeparture') assertValidWhen(s.plannedDeparture, cfg.when, name + '.plannedDeparture') } - if (is(s.plannedArrival) && !is(s.arrival)) { + if (is(s.plannedArrival) && !is(s.arrival) && !s.cancelled) { a.fail(name + ' has .plannedArrival but not .arrival') } - if (is(s.plannedDeparture) && !is(s.departure)) { + if (is(s.plannedDeparture) && !is(s.departure) && !s.cancelled) { a.fail(name + ' has .plannedDeparture but not .departure') } @@ -225,8 +225,8 @@ const createValidateJourneyLeg = (cfg) => { // FPTF doesn't support cancelled journey legs yet. // see https://github.com/public-transport/friendly-public-transport-format/issues/27 // todo: remove once this is resolved upstream - fakeLeg.departure = leg.formerScheduledDeparture - fakeLeg.arrival = leg.formerScheduledArrival + fakeLeg.departure = leg.plannedDeparture + fakeLeg.arrival = leg.plannedArrival } defaultValidators.journeyLeg(val, fakeLeg, name) @@ -272,9 +272,11 @@ const createValidateJourneyLeg = (cfg) => { a.strictEqual(typeof leg.tripId, 'string', name + '.tripId must be a string') a.ok(leg.tripId, name + '.tripId must not be empty') - const msg = name + '.direction must be a string' - a.strictEqual(typeof leg.direction, 'string', msg) - a.ok(leg.direction, name + '.direction must not be empty') + if (!leg.cancelled) { + const msg = name + '.direction must be a string' + a.strictEqual(typeof leg.direction, 'string', msg) + a.ok(leg.direction, name + '.direction must not be empty') + } } if ('cycle' in leg) {