adapt tests to 1c467cd

This commit is contained in:
Jannis R 2018-05-28 20:35:01 +02:00 committed by Jannis Redmann
parent c82ad234e0
commit a59b340d67
5 changed files with 54 additions and 43 deletions

View file

@ -101,7 +101,7 @@ const regensburgHbf = '8000309'
test('Berlin Jungfernheide to München Hbf', co(function* (t) { test('Berlin Jungfernheide to München Hbf', co(function* (t) {
const journeys = yield client.journeys(jungfernh, münchenHbf, { const journeys = yield client.journeys(jungfernh, münchenHbf, {
when, passedStations: true departure: when, passedStations: true
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -144,7 +144,7 @@ test('Berlin Jungfernheide to Torfstraße 17', co(function* (t) {
const journeys = yield client.journeys(jungfernh, { const journeys = yield client.journeys(jungfernh, {
type: 'location', address: 'Torfstraße 17', type: 'location', address: 'Torfstraße 17',
latitude: 52.5416823, longitude: 13.3491223 latitude: 52.5416823, longitude: 13.3491223
}, {when}) }, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -173,7 +173,7 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
const journeys = yield client.journeys(jungfernh, { const journeys = yield client.journeys(jungfernh, {
type: 'location', id: '991598902', name: 'ATZE Musiktheater', type: 'location', id: '991598902', name: 'ATZE Musiktheater',
latitude: 52.542417, longitude: 13.350437 latitude: 52.542417, longitude: 13.350437
}, {when}) }, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -207,7 +207,7 @@ test('journeys: via works with detour', co(function* (t) {
const [journey] = yield client.journeys(westhafen, wedding, { const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee, via: württembergallee,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -228,7 +228,7 @@ test('journeys: via works without detour', co(function* (t) {
const [journey] = yield client.journeys(ruhleben, zoo, { const [journey] = yield client.journeys(ruhleben, zoo, {
via: kastanienallee, via: kastanienallee,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -242,7 +242,7 @@ test('journeys: via works without detour', co(function* (t) {
test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) { test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
const model = yield client.journeys(jungfernh, münchenHbf, { const model = yield client.journeys(jungfernh, münchenHbf, {
results: 3, when results: 3, departure: when
}) })
t.equal(typeof model.earlierRef, 'string') t.equal(typeof model.earlierRef, 'string')
@ -253,12 +253,12 @@ test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
// when and earlierThan/laterThan should be mutually exclusive // when and earlierThan/laterThan should be mutually exclusive
t.throws(() => { t.throws(() => {
client.journeys(jungfernh, münchenHbf, { client.journeys(jungfernh, münchenHbf, {
when, earlierThan: model.earlierRef departure: when, earlierThan: model.earlierRef
}) })
}) })
t.throws(() => { t.throws(() => {
client.journeys(jungfernh, münchenHbf, { client.journeys(jungfernh, münchenHbf, {
when, laterThan: model.laterRef departure: when, laterThan: model.laterRef
}) })
}) })

View file

@ -70,7 +70,7 @@ test('Magdeburg Hbf to Magdeburg-Buckau', co(function*(t) {
const magdeburgHbf = '8010224' const magdeburgHbf = '8010224'
const magdeburgBuckau = '8013456' const magdeburgBuckau = '8013456'
const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, { const journeys = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
when, departure: when,
passedStations: true passedStations: true
}) })
@ -110,7 +110,7 @@ test('Magdeburg Hbf to 39104 Magdeburg, Sternstr. 10', co(function*(t) {
} }
const journeys = yield client.journeys(magdeburgHbf, sternStr, { const journeys = yield client.journeys(magdeburgHbf, sternStr, {
when departure: when
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -147,7 +147,7 @@ test('Kloster Unser Lieben Frauen to Magdeburg Hbf', co(function*(t) {
} }
const magdeburgHbf = '8010224' const magdeburgHbf = '8010224'
const journeys = yield client.journeys(kloster, magdeburgHbf, { const journeys = yield client.journeys(kloster, magdeburgHbf, {
when departure: when
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -185,7 +185,7 @@ test('journeys: via works with detour', co(function* (t) {
const [journey] = yield client.journeys(hasselbachplatzSternstrasse, stendal, { const [journey] = yield client.journeys(hasselbachplatzSternstrasse, stendal, {
via: dessau, via: dessau,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -208,7 +208,7 @@ test('journeys: via works without detour', co(function* (t) {
const [journey] = yield client.journeys(hasselbachplatzSternstrasse, universitaet, { const [journey] = yield client.journeys(hasselbachplatzSternstrasse, universitaet, {
via: breiterWeg, via: breiterWeg,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -270,7 +270,7 @@ test('journey leg details', co(function* (t) {
const magdeburgHbf = '8010224' const magdeburgHbf = '8010224'
const magdeburgBuckau = '8013456' const magdeburgBuckau = '8013456'
const [journey] = yield client.journeys(magdeburgHbf, magdeburgBuckau, { const [journey] = yield client.journeys(magdeburgHbf, magdeburgBuckau, {
results: 1, when results: 1, departure: when
}) })
const p = journey.legs[0] const p = journey.legs[0]

View file

@ -99,7 +99,7 @@ const schleswig = '8005362'
test('Kiel Hbf to Flensburg', co(function* (t) { test('Kiel Hbf to Flensburg', co(function* (t) {
const journeys = yield client.journeys(kielHbf, flensburg, { const journeys = yield client.journeys(kielHbf, flensburg, {
when, passedStations: true departure: when, passedStations: true
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -148,7 +148,7 @@ test('Kiel Hbf to Husum, Zingel 10', co(function* (t) {
address: 'Husum, Zingel 10' address: 'Husum, Zingel 10'
} }
const journeys = yield client.journeys(kielHbf, zingel, {when}) const journeys = yield client.journeys(kielHbf, zingel, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -185,7 +185,7 @@ test('Holstentor to Kiel Hbf', co(function* (t) {
name: 'Hansestadt Lübeck, Holstentor (Denkmal)', name: 'Hansestadt Lübeck, Holstentor (Denkmal)',
id: '970003547' id: '970003547'
} }
const journeys = yield client.journeys(holstentor, kielHbf, {when}) const journeys = yield client.journeys(holstentor, kielHbf, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -219,7 +219,7 @@ test('Husum to Lübeck Hbf with stopover at Husum', co(function* (t) {
const [journey] = yield client.journeys(husum, luebeckHbf, { const [journey] = yield client.journeys(husum, luebeckHbf, {
via: kielHbf, via: kielHbf,
results: 1, results: 1,
when departure: when
}) })
const i1 = journey.legs.findIndex(leg => leg.destination.id === kielHbf) const i1 = journey.legs.findIndex(leg => leg.destination.id === kielHbf)
@ -234,7 +234,7 @@ test('Husum to Lübeck Hbf with stopover at Husum', co(function* (t) {
test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) { test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
const model = yield client.journeys(kielHbf, flensburg, { const model = yield client.journeys(kielHbf, flensburg, {
results: 3, when results: 3, departure: when
}) })
t.equal(typeof model.earlierRef, 'string') t.equal(typeof model.earlierRef, 'string')
@ -245,12 +245,12 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
// when and earlierThan/laterThan should be mutually exclusive // when and earlierThan/laterThan should be mutually exclusive
t.throws(() => { t.throws(() => {
client.journeys(kielHbf, flensburg, { client.journeys(kielHbf, flensburg, {
when, earlierThan: model.earlierRef departure: when, earlierThan: model.earlierRef
}) })
}) })
t.throws(() => { t.throws(() => {
client.journeys(kielHbf, flensburg, { client.journeys(kielHbf, flensburg, {
when, laterThan: model.laterRef departure: when, laterThan: model.laterRef
}) })
}) })
@ -284,7 +284,7 @@ test('earlier/later journeys, Kiel Hbf -> Flensburg', co(function* (t) {
test('leg details for Flensburg to Husum', co(function* (t) { test('leg details for Flensburg to Husum', co(function* (t) {
const journeys = yield client.journeys(flensburg, husum, { const journeys = yield client.journeys(flensburg, husum, {
results: 1, when results: 1, departure: when
}) })
const p = journeys[0].legs[0] const p = journeys[0].legs[0]

View file

@ -120,7 +120,7 @@ const grazHbf = '8100173'
test('Salzburg Hbf to Wien Westbahnhof', co(function* (t) { test('Salzburg Hbf to Wien Westbahnhof', co(function* (t) {
const journeys = yield client.journeys(salzburgHbf, wienWestbahnhof, { const journeys = yield client.journeys(salzburgHbf, wienWestbahnhof, {
when, passedStations: true departure: when, passedStations: true
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -169,7 +169,7 @@ test('Salzburg Hbf to 1220 Wien, Wagramer Straße 5', co(function* (t) {
address: '1220 Wien, Wagramer Straße 5' address: '1220 Wien, Wagramer Straße 5'
} }
const journeys = yield client.journeys(salzburgHbf, wagramerStr, {when}) const journeys = yield client.journeys(salzburgHbf, wagramerStr, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -206,7 +206,7 @@ test('Albertina to Salzburg Hbf', co(function* (t) {
name: 'Albertina', name: 'Albertina',
id: '975900003' id: '975900003'
} }
const journeys = yield client.journeys(albertina, salzburgHbf, {when}) const journeys = yield client.journeys(albertina, salzburgHbf, {departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.ok(journeys.length >= 1, 'no journeys') t.ok(journeys.length >= 1, 'no journeys')
@ -246,7 +246,7 @@ test('journeys: via works with detour', co(function* (t) {
const [journey] = yield client.journeys(stephansplatz, schottenring, { const [journey] = yield client.journeys(stephansplatz, schottenring, {
via: donauinsel, via: donauinsel,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -269,7 +269,7 @@ test('journeys: via works without detour', co(function* (t) {
const [journey] = yield client.journeys(karlsplatz, praterstern, { const [journey] = yield client.journeys(karlsplatz, praterstern, {
via: museumsquartier, via: museumsquartier,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -283,7 +283,7 @@ test('journeys: via works without detour', co(function* (t) {
test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t) { test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t) {
const model = yield client.journeys(salzburgHbf, wienWestbahnhof, { const model = yield client.journeys(salzburgHbf, wienWestbahnhof, {
results: 3, when results: 3, departure: when
}) })
t.equal(typeof model.earlierRef, 'string') t.equal(typeof model.earlierRef, 'string')
@ -294,12 +294,12 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t
// when and earlierThan/laterThan should be mutually exclusive // when and earlierThan/laterThan should be mutually exclusive
t.throws(() => { t.throws(() => {
client.journeys(salzburgHbf, wienWestbahnhof, { client.journeys(salzburgHbf, wienWestbahnhof, {
when, earlierThan: model.earlierRef departure: when, earlierThan: model.earlierRef
}) })
}) })
t.throws(() => { t.throws(() => {
client.journeys(salzburgHbf, wienWestbahnhof, { client.journeys(salzburgHbf, wienWestbahnhof, {
when, laterThan: model.laterRef departure: when, laterThan: model.laterRef
}) })
}) })
@ -333,7 +333,7 @@ test('earlier/later journeys, Salzburg Hbf -> Wien Westbahnhof', co(function* (t
test('leg details for Wien Westbahnhof to München Hbf', co(function* (t) { test('leg details for Wien Westbahnhof to München Hbf', co(function* (t) {
const journeys = yield client.journeys(wienWestbahnhof, muenchenHbf, { const journeys = yield client.journeys(wienWestbahnhof, muenchenHbf, {
results: 1, when results: 1, departure: when
}) })
const p = journeys[0].legs[0] const p = journeys[0].legs[0]

View file

@ -60,7 +60,7 @@ const bismarckstr = '900000024201'
test('journeys  station to station', co(function* (t) { test('journeys  station to station', co(function* (t) {
const journeys = yield client.journeys(spichernstr, amrumerStr, { const journeys = yield client.journeys(spichernstr, amrumerStr, {
results: 3, when, passedStations: true results: 3, departure: when, passedStations: true
}) })
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
@ -108,7 +108,7 @@ test('journeys  station to station', co(function* (t) {
test('journeys  only subway', co(function* (t) { test('journeys  only subway', co(function* (t) {
const journeys = yield client.journeys(spichernstr, bismarckstr, { const journeys = yield client.journeys(spichernstr, bismarckstr, {
results: 20, when, results: 20, departure: when,
products: { products: {
suburban: false, suburban: false,
subway: true, subway: true,
@ -136,9 +136,10 @@ test('journeys  only subway', co(function* (t) {
})) }))
test('journeys  fails with no product', co(function* (t) { test('journeys  fails with no product', co(function* (t) {
t.plan(1)
try { try {
client.journeys(spichernstr, bismarckstr, { client.journeys(spichernstr, bismarckstr, {
when, departure: when,
products: { products: {
suburban: false, suburban: false,
subway: false, subway: false,
@ -159,7 +160,7 @@ test('journeys  fails with no product', co(function* (t) {
test('earlier/later journeys', co(function* (t) { test('earlier/later journeys', co(function* (t) {
const model = yield client.journeys(spichernstr, bismarckstr, { const model = yield client.journeys(spichernstr, bismarckstr, {
results: 3, when results: 3, departure: when
}) })
t.equal(typeof model.earlierRef, 'string') t.equal(typeof model.earlierRef, 'string')
@ -167,15 +168,25 @@ test('earlier/later journeys', co(function* (t) {
t.equal(typeof model.laterRef, 'string') t.equal(typeof model.laterRef, 'string')
t.ok(model.laterRef) t.ok(model.laterRef)
// when and earlierThan/laterThan should be mutually exclusive // departure/arrival and earlierThan/laterThan should be mutually exclusive
t.throws(() => { t.throws(() => {
client.journeys(spichernstr, bismarckstr, { client.journeys(spichernstr, bismarckstr, {
when, earlierThan: model.earlierRef departure: when, earlierThan: model.earlierRef
}) })
}) })
t.throws(() => { t.throws(() => {
client.journeys(spichernstr, bismarckstr, { client.journeys(spichernstr, bismarckstr, {
when, laterThan: model.laterRef departure: when, laterThan: model.laterRef
})
})
t.throws(() => {
client.journeys(spichernstr, bismarckstr, {
arrival: when, earlierThan: model.earlierRef
})
})
t.throws(() => {
client.journeys(spichernstr, bismarckstr, {
arrival: when, laterThan: model.laterRef
}) })
}) })
@ -209,7 +220,7 @@ test('earlier/later journeys', co(function* (t) {
test('journey leg details', co(function* (t) { test('journey leg details', co(function* (t) {
const journeys = yield client.journeys(spichernstr, amrumerStr, { const journeys = yield client.journeys(spichernstr, amrumerStr, {
results: 1, when results: 1, departure: when
}) })
const p = journeys[0].legs[0] const p = journeys[0].legs[0]
@ -238,7 +249,7 @@ test('journeys  station to address', co(function* (t) {
type: 'location', type: 'location',
address: 'Torfstr. 17, Berlin', address: 'Torfstr. 17, Berlin',
latitude: 52.541797, longitude: 13.350042 latitude: 52.541797, longitude: 13.350042
}, {results: 1, when}) }, {results: 1, departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.strictEqual(journeys.length, 1) t.strictEqual(journeys.length, 1)
@ -267,7 +278,7 @@ test('journeys  station to POI', co(function* (t) {
id: '900980720', id: '900980720',
name: 'Berlin, Atze Musiktheater für Kinder', name: 'Berlin, Atze Musiktheater für Kinder',
latitude: 52.543333, longitude: 13.351686 latitude: 52.543333, longitude: 13.351686
}, {results: 1, when}) }, {results: 1, departure: when})
t.ok(Array.isArray(journeys)) t.ok(Array.isArray(journeys))
t.strictEqual(journeys.length, 1) t.strictEqual(journeys.length, 1)
@ -298,7 +309,7 @@ test('journeys: via works with detour', co(function* (t) {
const [journey] = yield client.journeys(westhafen, wedding, { const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee, via: württembergallee,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })
@ -319,7 +330,7 @@ test('journeys: via works without detour', co(function* (t) {
const [journey] = yield client.journeys(ruhleben, zoo, { const [journey] = yield client.journeys(ruhleben, zoo, {
via: kastanienallee, via: kastanienallee,
results: 1, results: 1,
when, departure: when,
passedStations: true passedStations: true
}) })