mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tests: adapt to ctx-based parse fns
This commit is contained in:
parent
9fc6664302
commit
2cfee22287
4 changed files with 14 additions and 14 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue