From 2cfee2228761173fccdaa5141d430f1225725da2 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 25 Oct 2019 23:42:17 +0200 Subject: [PATCH] tests: adapt to ctx-based parse fns --- test/bvg-journey.js | 8 ++++---- test/bvg-radar.js | 8 ++++---- test/throttle.js | 4 ++-- test/vbb-departures.js | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/bvg-journey.js b/test/bvg-journey.js index f81305a4..951dfdf7 100644 --- a/test/bvg-journey.js +++ b/test/bvg-journey.js @@ -5,7 +5,7 @@ const tape = require('tape') const createClient = require('..') const rawProfile = require('../p/bvg') -const raw = require('./fixtures/bvg-journey.json') +const res = require('./fixtures/bvg-journey.json') const expected = require('./fixtures/bvg-journey.js') const test = tapePromise(tape) @@ -31,9 +31,9 @@ const opt = { } test('parses a journey correctly (BVG)', (t) => { - const common = profile.parseCommon(profile, opt, raw) - const parseJourney = profile.parseJourney(profile, opt, common) - const journey = parseJourney(common.outConL[0]) + const common = profile.parseCommon({profile, opt, res}) + const ctx = {profile, opt, common, res} + const journey = profile.parseJourney(ctx, res.outConL[0]) t.deepEqual(journey, expected) t.end() diff --git a/test/bvg-radar.js b/test/bvg-radar.js index 8c514a67..4f0a3eaa 100644 --- a/test/bvg-radar.js +++ b/test/bvg-radar.js @@ -5,7 +5,7 @@ const tape = require('tape') const createClient = require('..') const rawProfile = require('../p/bvg') -const raw = require('./fixtures/bvg-radar.json') +const res = require('./fixtures/bvg-radar.json') const expected = require('./fixtures/bvg-radar.js') const test = tapePromise(tape) @@ -23,9 +23,9 @@ const opt = { } test('parses a radar() response correctly (BVG)', (t) => { - const common = profile.parseCommon(profile, opt, raw) - const parseMovement = profile.parseMovement(profile, opt, common) - const movements = raw.jnyL.map(parseMovement) + const common = profile.parseCommon({profile, opt, res}) + const ctx = {profile, opt, common, res} + const movements = res.jnyL.map(m => profile.parseMovement(ctx, m)) t.deepEqual(movements, expected) t.end() diff --git a/test/throttle.js b/test/throttle.js index 64a31737..15c8045f 100644 --- a/test/throttle.js +++ b/test/throttle.js @@ -12,9 +12,9 @@ const spichernstr = '900000042101' // todo: mock request() test('withThrottling works', (t) => { let calls = 0 - const transformReqBody = (body) => { + const transformReqBody = (ctx, body) => { calls++ - return vbbProfile.transformReqBody(body) + return vbbProfile.transformReqBody(ctx, body) } const mockProfile = Object.assign({}, vbbProfile, {transformReqBody}) diff --git a/test/vbb-departures.js b/test/vbb-departures.js index 3938a945..c2effa20 100644 --- a/test/vbb-departures.js +++ b/test/vbb-departures.js @@ -5,7 +5,7 @@ const tape = require('tape') const createClient = require('..') const rawProfile = require('../p/vbb') -const raw = require('./fixtures/vbb-departures.json') +const res = require('./fixtures/vbb-departures.json') const expected = require('./fixtures/vbb-departures.js') const test = tapePromise(tape) @@ -24,9 +24,9 @@ const opt = { } test('parses a departure correctly (VBB)', (t) => { - const common = profile.parseCommon(profile, opt, raw) - const parseDeparture = profile.parseDeparture(profile, opt, common) - const departures = raw.jnyL.map(parseDeparture) + const common = profile.parseCommon({profile, opt, res}) + const ctx = {profile, opt, common, res} + const departures = res.jnyL.map(d => profile.parseDeparture(ctx, d)) t.deepEqual(departures, expected) t.end()