diff --git a/js/id/presets.js b/js/id/presets.js index 858cbc834..f7732ed9a 100644 --- a/js/id/presets.js +++ b/js/id/presets.js @@ -74,7 +74,7 @@ iD.presets = function() { if (ignore.indexOf(key) !== -1) return; var value = d.tags[key]; - if (d.geometry.indexOf('area') === -1 && key in areaKeys && value !== '*') { + if (d.geometry.indexOf('line') !== -1 && key in areaKeys && value !== '*') { areaKeys[key][value] = true; } }); diff --git a/test/spec/presets.js b/test/spec/presets.js index 01eb21a89..dbfd4b2ed 100644 --- a/test/spec/presets.js +++ b/test/spec/presets.js @@ -43,28 +43,59 @@ describe("iD.presets", function() { describe("#areaKeys", function() { var presets = iD.presets().load({ presets: { - a: { - tags: { - a: '*' - }, - geometry: ['point', 'line', 'area'] + 'amenity/fuel/shell': { + tags: { 'amenity': 'fuel' }, + geometry: ['point','area'], + suggestion: true }, - ab: { - tags: { - a: 'b' - }, + 'highway/foo': { + tags: { 'highway': 'foo' }, + geometry: ['area'] + }, + 'natural': { + tags: { 'natural': '*' }, + geometry: ['point', 'vertex', 'area'] + }, + 'natural/peak': { + tags: { 'natural': 'peak' }, + geometry: ['point', 'vertex'] + }, + 'natural/tree_row': { + tags: { 'natural': 'tree_row' }, geometry: ['line'] } + 'natural/wood': { + tags: { 'natural': 'wood' }, + geometry: ['point', 'area'] + } } }); - it("whitelists keys from presets with area geometry", function() { - expect(presets.areaKeys()).to.have.key('a'); + it("whitelists keys for presets with area geometry", function() { + expect(presets.areaKeys()).to.have.key('natural'); }); - it("blacklists key-values from presets without an area geometry", function() { - expect(presets.areaKeys().a.b).to.eq(true); + it("blacklists key-values for presets with a line geometry", function() { + expect(presets.areaKeys().natural).to.have.key('tree_row'); + expect(presets.areaKeys().natural.tree_row).to.eq(true); }); + + it("does not blacklist key-values for presets without a line geometry (e.g. used only on nodes)", function() { + expect(presets.areaKeys().natural).not.to.have.key('peak'); + }); + + it("does not blacklist generic '*' key-values", function() { + expect(presets.areaKeys().natural).not.to.have.key('natural'); + }); + + it("ignores keys like 'highway'", function() { + expect(presets.areaKeys()).not.to.have.key('highway'); + }); + + it("ignores suggestion presets", function() { + expect(presets.areaKeys()).not.to.have.key('amenity'); + }); + }); describe("expected matches", function() {