Simplify unpaved tag class logic, add tests

(re: #5422)
This commit is contained in:
Bryan Housel
2018-10-31 16:13:03 -04:00
parent b79f87f511
commit 3e03102731
2 changed files with 26 additions and 9 deletions
+1 -8
View File
@@ -86,7 +86,7 @@ export function svgTagClasses() {
}
// For highways, look for surface tagging..
if (primary === 'highway') {
if (primary === 'highway' || primary === 'aeroway') {
var paved = (t.highway !== 'track');
for (k in t) {
v = t[k];
@@ -100,13 +100,6 @@ export function svgTagClasses() {
}
}
// Style unpaved taxiways
if (primary === 'aeroway') {
if (t.aeroway === 'taxiway' && t.surface === 'unpaved') {
classes += ' tag-unpaved';
}
}
classes = classes.trim();
if (classes !== value) {
+25 -1
View File
@@ -137,6 +137,18 @@ describe('iD.svgTagClasses', function () {
expect(selection.classed('tag-unpaved')).to.be.false;
});
it('does not add tag-unpaved for other aeroway types with explicit paved surface tagging', function() {
selection
.datum(iD.osmEntity({tags: {aeroway: 'taxiway', surface: 'asphalt'}}))
.call(iD.svgTagClasses());
expect(selection.classed('tag-unpaved')).to.be.false;
selection
.datum(iD.osmEntity({tags: {aeroway: 'runway', surface: 'paved'}}))
.call(iD.svgTagClasses());
expect(selection.classed('tag-unpaved')).to.be.false;
});
it('adds tag-unpaved for other highway types with explicit unpaved surface tagging', function() {
selection
.datum(iD.osmEntity({tags: {highway: 'tertiary', surface: 'dirt'}}))
@@ -149,7 +161,19 @@ describe('iD.svgTagClasses', function () {
expect(selection.classed('tag-unpaved')).to.be.true;
});
it('does not add tag-unpaved for non-highways', function() {
it('adds tag-unpaved for other aeroway types with explicit unpaved surface tagging', function() {
selection
.datum(iD.osmEntity({tags: {aeroway: 'taxiway', surface: 'dirt'}}))
.call(iD.svgTagClasses());
expect(selection.classed('tag-unpaved')).to.be.true;
selection
.datum(iD.osmEntity({tags: {aeroway: 'runway', surface: 'unpaved'}}))
.call(iD.svgTagClasses());
expect(selection.classed('tag-unpaved')).to.be.true;
});
it('does not add tag-unpaved for non-highways/aeroways', function() {
selection
.datum(iD.osmEntity({tags: {railway: 'abandoned', surface: 'gravel'}}))
.call(iD.svgTagClasses());