-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create compare_static_ubahn_stations_with_puls.js
- Loading branch information
1 parent
990ad30
commit 1310d8b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Example test: compare station key to API (PULS) Haltestellenname | ||
*/ | ||
const { expect } = require('chai'); | ||
|
||
const bahnhoefe = require('../static/bahnhoefe-u-bahn.json'); | ||
|
||
describe('Compare station key to VAG API Haltestellenname', function () { | ||
this.timeout(10000); | ||
this.slow(2500); | ||
|
||
Object.entries(bahnhoefe).forEach(([stationNameKey, stationData]) => { | ||
it(`should match key "${stationNameKey}" to Haltestellenname`, async () => { | ||
const uBahnhofKurz = stationData['u-bahnhof_kurz']; | ||
|
||
const url = `https://start.vag.de/dm/api/v1/abfahrten/VAG/${uBahnhofKurz}`; | ||
const response = await fetch(url); | ||
const apiData = await response.json(); | ||
|
||
const apiHaltestellenname = apiData.Haltestellenname | ||
.replace(/\s*\(.*\)/, '') | ||
.trim(); | ||
|
||
const trimmedStationNameKey = stationNameKey.trim(); | ||
expect(apiHaltestellenname).to.equal(trimmedStationNameKey); | ||
}); | ||
}); | ||
}); |