From 2f9918f77433c159b0a7bbc081931ae581e9f205 Mon Sep 17 00:00:00 2001 From: Erik Timmers Date: Tue, 22 Jul 2014 13:01:04 +0200 Subject: [PATCH] Add tests for GPX extensions --- test/spec/ol/format/gpxformat.test.js | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/spec/ol/format/gpxformat.test.js b/test/spec/ol/format/gpxformat.test.js index 7d880ed391..1a0f9c7180 100644 --- a/test/spec/ol/format/gpxformat.test.js +++ b/test/spec/ol/format/gpxformat.test.js @@ -394,6 +394,73 @@ describe('ol.format.GPX', function() { }); + describe('extensions support', function() { + + beforeEach(function() { + format = new ol.format.GPX({ + readExtensions: function(feature, extensionsNode) { + var nodes = extensionsNode.getElementsByTagName('id'); + var id = nodes.item(0).textContent; + feature.setId(id); + } + }); + }); + + it('can process extensions from wpt', function() { + var text = + '' + + ' ' + + ' ' + + ' feature-id' + + ' ' + + ' ' + + ''; + var fs = format.readFeatures(text); + expect(fs).to.have.length(1); + var feature = fs[0]; + expect(feature.getId()).to.be('feature-id'); + }); + + it('can process extensions from rte', function() { + var text = + '' + + ' ' + + ' ' + + ' bar' + + ' feature-id' + + ' ' + + ' ' + + ''; + var fs = format.readFeatures(text); + expect(fs).to.have.length(1); + var feature = fs[0]; + expect(feature.getId()).to.be('feature-id'); + }); + + it('can process extensions from trk, not trkpt', function() { + var text = + '' + + ' ' + + ' ' + + ' feature-id' + + ' ' + + ' ' + + ' ' + + ' ' + + ' another-feature-id' + + ' ' + + ' ' + + ' ' + + ' ' + + ''; + var fs = format.readFeatures(text); + expect(fs).to.have.length(1); + var feature = fs[0]; + expect(feature.getId()).to.be('feature-id'); + }); + + }); + }); });