Skip to content

Commit

Permalink
Create compare_static_ubahn_stations_with_puls.js
Browse files Browse the repository at this point in the history
Test to find #11 and #12
  • Loading branch information
BolverBlitz committed Jan 4, 2025
1 parent 990ad30 commit 1310d8b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/compare_static_ubahn_stations_with_puls.js
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);
});
});
});

0 comments on commit 1310d8b

Please sign in to comment.