mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tests: DB stop(), INSA stop() ✅
This commit is contained in:
parent
ff2b677812
commit
b9d5c85a54
7 changed files with 15715 additions and 0 deletions
27
test/db-stop.js
Normal file
27
test/db-stop.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const tapePromise = require('tape-promise').default
|
||||||
|
const tape = require('tape')
|
||||||
|
|
||||||
|
const createClient = require('..')
|
||||||
|
const rawProfile = require('../p/db')
|
||||||
|
const res = require('./fixtures/db-stop.json')
|
||||||
|
const expected = require('./fixtures/db-stop.js')
|
||||||
|
|
||||||
|
const test = tapePromise(tape)
|
||||||
|
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
|
||||||
|
const {profile} = client
|
||||||
|
|
||||||
|
const opt = {
|
||||||
|
linesOfStops: false, // parse & expose lines at the stop/station?
|
||||||
|
remarks: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
test('parses a stop() response correctly (DB)', (t) => {
|
||||||
|
const common = profile.parseCommon({profile, opt, res})
|
||||||
|
const ctx = {profile, opt, common, res}
|
||||||
|
const stop = profile.parseLocation(ctx, res.locL[0])
|
||||||
|
|
||||||
|
t.deepEqual(stop, expected)
|
||||||
|
t.end()
|
||||||
|
})
|
25
test/fixtures/db-stop.js
vendored
Normal file
25
test/fixtures/db-stop.js
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
type: 'stop',
|
||||||
|
id: '8011155',
|
||||||
|
name: 'Berlin Alexanderplatz',
|
||||||
|
location: {
|
||||||
|
type: 'location',
|
||||||
|
id: '8011155',
|
||||||
|
latitude: 52.521526,
|
||||||
|
longitude: 13.411088
|
||||||
|
},
|
||||||
|
products: {
|
||||||
|
nationalExpress: false,
|
||||||
|
national: false,
|
||||||
|
regionalExp: false,
|
||||||
|
regional: true,
|
||||||
|
suburban: true,
|
||||||
|
bus: true,
|
||||||
|
ferry: false,
|
||||||
|
subway: true,
|
||||||
|
tram: true,
|
||||||
|
taxi: false
|
||||||
|
}
|
||||||
|
}
|
15509
test/fixtures/db-stop.json
vendored
Normal file
15509
test/fixtures/db-stop.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
22
test/fixtures/insa-stop.js
vendored
Normal file
22
test/fixtures/insa-stop.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
type: 'stop',
|
||||||
|
id: '7341',
|
||||||
|
name: 'Magdeburg, S-Bahnhof SKET Industriepark',
|
||||||
|
location: {
|
||||||
|
type: 'location',
|
||||||
|
id: '7341',
|
||||||
|
latitude: 52.096849,
|
||||||
|
longitude: 11.637444
|
||||||
|
},
|
||||||
|
products: {
|
||||||
|
nationalExpress: false,
|
||||||
|
national: false,
|
||||||
|
regional: false,
|
||||||
|
suburban: false,
|
||||||
|
tram: false,
|
||||||
|
bus: true,
|
||||||
|
tourismTrain: false
|
||||||
|
},
|
||||||
|
}
|
103
test/fixtures/insa-stop.json
vendored
Normal file
103
test/fixtures/insa-stop.json
vendored
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"locL": [
|
||||||
|
{
|
||||||
|
"lid": "A=1@O=Magdeburg SKET Industriepark@X=11638280@Y=52097541@U=80@L=8013485@",
|
||||||
|
"type": "S",
|
||||||
|
"name": "Magdeburg SKET Industriepark",
|
||||||
|
"icoX": 2,
|
||||||
|
"extId": "8013485",
|
||||||
|
"state": "F",
|
||||||
|
"crd": {
|
||||||
|
"x": 11638280,
|
||||||
|
"y": 52097541
|
||||||
|
},
|
||||||
|
"pCls": 88,
|
||||||
|
"rRefL": [
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"prodL": [],
|
||||||
|
"opL": [
|
||||||
|
{
|
||||||
|
"name": "Magdeburger Verkehrsbetriebe",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remL": [
|
||||||
|
{
|
||||||
|
"type": "I",
|
||||||
|
"code": "IF",
|
||||||
|
"icoX": 0,
|
||||||
|
"txtN": "de:15003:7341"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "I",
|
||||||
|
"code": "IF",
|
||||||
|
"icoX": 0,
|
||||||
|
"txtN": "de:15003:8013485"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "I",
|
||||||
|
"code": "TD",
|
||||||
|
"icoX": 0,
|
||||||
|
"txtN": "8013485"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icoL": [
|
||||||
|
{
|
||||||
|
"res": "INFO"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"res": "prod_bus",
|
||||||
|
"fg": {
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"bg": {
|
||||||
|
"r": 170,
|
||||||
|
"g": 85,
|
||||||
|
"b": 153,
|
||||||
|
"a": 255
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"res": "prod_reg",
|
||||||
|
"fg": {
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"bg": {
|
||||||
|
"r": 17,
|
||||||
|
"g": 137,
|
||||||
|
"b": 56,
|
||||||
|
"a": 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locL": [
|
||||||
|
{
|
||||||
|
"lid": "A=1@O=Magdeburg, S-Bahnhof SKET Industriepark@X=11637444@Y=52096849@U=80@L=7341@",
|
||||||
|
"type": "S",
|
||||||
|
"name": "Magdeburg, S-Bahnhof SKET Industriepark",
|
||||||
|
"icoX": 1,
|
||||||
|
"extId": "7341",
|
||||||
|
"state": "F",
|
||||||
|
"crd": {
|
||||||
|
"x": 11637444,
|
||||||
|
"y": 52096849
|
||||||
|
},
|
||||||
|
"pCls": 64,
|
||||||
|
"rRefL": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
require('./parse')
|
require('./parse')
|
||||||
require('./format')
|
require('./format')
|
||||||
|
|
||||||
|
require('./db-stop')
|
||||||
|
require('./insa-stop')
|
||||||
require('./bvg-journey')
|
require('./bvg-journey')
|
||||||
require('./vbb-departures')
|
require('./vbb-departures')
|
||||||
require('./bvg-radar')
|
require('./bvg-radar')
|
||||||
|
|
27
test/insa-stop.js
Normal file
27
test/insa-stop.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const tapePromise = require('tape-promise').default
|
||||||
|
const tape = require('tape')
|
||||||
|
|
||||||
|
const createClient = require('..')
|
||||||
|
const rawProfile = require('../p/insa')
|
||||||
|
const res = require('./fixtures/insa-stop.json')
|
||||||
|
const expected = require('./fixtures/insa-stop.js')
|
||||||
|
|
||||||
|
const test = tapePromise(tape)
|
||||||
|
const client = createClient(rawProfile, 'public-transport/hafas-client:test')
|
||||||
|
const {profile} = client
|
||||||
|
|
||||||
|
const opt = {
|
||||||
|
linesOfStops: false, // parse & expose lines at the stop/station?
|
||||||
|
remarks: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
test('parses a stop() response correctly (INSA)', (t) => {
|
||||||
|
const common = profile.parseCommon({profile, opt, res})
|
||||||
|
const ctx = {profile, opt, common, res}
|
||||||
|
const stop = profile.parseLocation(ctx, res.locL[0])
|
||||||
|
|
||||||
|
t.deepEqual(stop, expected)
|
||||||
|
t.end()
|
||||||
|
})
|
Loading…
Add table
Reference in a new issue