Format Locus voice hint, with additional hint data

This commit is contained in:
Norbert Renner 2021-02-24 19:52:45 +01:00
parent a9d27b4674
commit fd0ece0d31
5 changed files with 152 additions and 39 deletions

View file

@ -31,7 +31,7 @@ function adoptGpx(gpx) {
}
function read(fileName) {
return adoptGpx(fs.readFileSync(path + fileName, 'utf8'));
return BR.Gpx.pretty(adoptGpx(fs.readFileSync(path + fileName, 'utf8')));
}
test('simple track', () => {
@ -41,8 +41,18 @@ test('simple track', () => {
});
describe('voice hints', () => {
test('2-locus', () => {
let brouterGpx = read('2-locus.gpx');
brouterGpx = brouterGpx.replace(/<(\/?)locus:/g, '<$1'); // TODO 'locus:' namespace
brouterGpx = brouterGpx.replace(/.0<\/rteDistance/g, '</rteDistance'); // ignore .0 decimal
brouterGpx = brouterGpx.replace(/\n\s*<\/extensions>\n\s*<extensions>/, ''); // ignore (invalid) double tag
const gpx = BR.Gpx.format(geoJson, 2);
expect(gpx).toEqual(brouterGpx);
});
test('5-gpsies', () => {
const brouterGpx = BR.Gpx.pretty(read('5-gpsies.gpx'));
const brouterGpx = read('5-gpsies.gpx');
const gpx = BR.Gpx.format(geoJson, 5);
expect(gpx).toEqual(brouterGpx);
});