mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
add missing test helper fn
This commit is contained in:
parent
c769638005
commit
7f02bfe4d5
1 changed files with 21 additions and 0 deletions
21
test/lib/departures.js
Normal file
21
test/lib/departures.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict'
|
||||
|
||||
const co = require('./co')
|
||||
|
||||
const testDepartures = co(function* (cfg) {
|
||||
const {test: t, departures: deps, validate, id} = cfg
|
||||
|
||||
validate(t, deps, 'departures', 'departures')
|
||||
t.ok(deps.length > 0, 'must be >0 departures')
|
||||
for (let i = 0; i < deps.length; i++) {
|
||||
const dep = deps[i]
|
||||
const name = `deps[${i}]`
|
||||
|
||||
t.equal(dep.station.id, id, name + '.station.id is invalid')
|
||||
}
|
||||
|
||||
// todo: move into deps validator
|
||||
t.deepEqual(deps, deps.sort((a, b) => t.when > b.when))
|
||||
})
|
||||
|
||||
module.exports = testDepartures
|
Loading…
Add table
Reference in a new issue