diff --git a/test/compare_static_ubahn_stations_with_puls.js b/test/compare_static_ubahn_stations_with_puls.js new file mode 100644 index 0000000..0ed7e6a --- /dev/null +++ b/test/compare_static_ubahn_stations_with_puls.js @@ -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); + }); + }); +}); \ No newline at end of file