overhaul gpx creation and usage
This commit is contained in:
+22
-1
@@ -1,3 +1,4 @@
|
||||
import { parseGpx } from '../src/services/gpx.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
@@ -209,7 +210,27 @@ assert result['ok'] is True
|
||||
assert.equal(route.gpxUrl, `/api/routes/${route.id}/gpx`);
|
||||
const { response: gpxResponse, body: downloadedGpx } = await requestBuffer(`${baseUrl}${route.gpxUrl}`);
|
||||
assert.match(gpxResponse.headers.get('content-type') || '', /application\/gpx\+xml/);
|
||||
assert.deepEqual(downloadedGpx, gpx);
|
||||
assert.match(downloadedGpx.toString(), /<rtept /);
|
||||
assert.doesNotMatch(downloadedGpx.toString(), /<trkpt /);
|
||||
assert.deepEqual(parseGpx(downloadedGpx.toString()).points, parseGpx(gpx.toString()).points);
|
||||
|
||||
const { body: pendingPoi } = await requestJson(`${baseUrl}/api/routes/${route.id}/pois`, {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ title: 'Ohne Empfang', lat: null, lon: null })
|
||||
}, 201);
|
||||
assert.equal(pendingPoi.lat, null);
|
||||
assert.equal(pendingPoi.lon, null);
|
||||
const { body: pendingGpx } = await requestBuffer(`${baseUrl}${route.gpxUrl}`);
|
||||
assert.match(pendingGpx.toString(), /wegwichtel:pendingWaypoint/);
|
||||
const { body: locatedPoi } = await requestJson(`${baseUrl}/api/routes/${route.id}/pois/${pendingPoi.id}`, {
|
||||
method: 'PUT', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ lat: 50, lon: 10 })
|
||||
});
|
||||
assert.equal(locatedPoi.lat, 50);
|
||||
const { body: locatedGpx } = await requestBuffer(`${baseUrl}${route.gpxUrl}`);
|
||||
assert.doesNotMatch(locatedGpx.toString(), /wegwichtel:pendingWaypoint/);
|
||||
assert.match(locatedGpx.toString(), /<wpt lat="50" lon="10">/);
|
||||
await requestJson(`${baseUrl}/api/routes/${route.id}/pois/${pendingPoi.id}`, { method: 'DELETE' });
|
||||
|
||||
const { body: poi } = await requestJson(`${baseUrl}/api/routes/${route.id}/pois`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user