From 0c5f563a262edbea4911da0c4f65f380975e6276 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 9 Jun 2014 23:39:16 -0400 Subject: [PATCH] add test for iD.Entity.layer(), fix spelling of man_made. --- js/id/core/way.js | 2 +- test/spec/core/way.js | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/js/id/core/way.js b/js/id/core/way.js index 12af9e6f0..53cb717fd 100644 --- a/js/id/core/way.js +++ b/js/id/core/way.js @@ -60,7 +60,7 @@ _.extend(iD.Way.prototype, { if (this.tags.cutting) return -1; if (this.tags.tunnel) return -1; if (this.tags.waterway) return -1; - if (this.tags.manmade === 'pipeline') return -10; + if (this.tags.man_made === 'pipeline') return -10; if (this.tags.boundary) return -10; return 0; }, diff --git a/test/spec/core/way.js b/test/spec/core/way.js index 5ff68c431..799b6a224 100644 --- a/test/spec/core/way.js +++ b/test/spec/core/way.js @@ -148,6 +148,68 @@ describe('iD.Way', function() { }); }); + describe('#layer', function() { + it('returns 0 when the way has no tags', function() { + expect(iD.Way().layer()).to.equal(0); + }); + + it('returns the layer when the way has an explicit layer tag', function() { + expect(iD.Way({tags: { layer: '2' }}).layer()).to.equal(2); + expect(iD.Way({tags: { layer: '-5' }}).layer()).to.equal(-5); + }); + + it('clamps the layer to within -10, 10', function() { + expect(iD.Way({tags: { layer: '12' }}).layer()).to.equal(10); + expect(iD.Way({tags: { layer: '-15' }}).layer()).to.equal(-10); + }); + + it('returns 1 for location=overground', function() { + expect(iD.Way({tags: { location: 'overground' }}).layer()).to.equal(1); + }); + + it('returns -1 for location=underground', function() { + expect(iD.Way({tags: { location: 'underground' }}).layer()).to.equal(-1); + }); + + it('returns -10 for location=underwater', function() { + expect(iD.Way({tags: { location: 'underwater' }}).layer()).to.equal(-10); + }); + + it('returns 10 for power lines', function() { + expect(iD.Way({tags: { power: 'line' }}).layer()).to.equal(10); + expect(iD.Way({tags: { power: 'minor_line' }}).layer()).to.equal(10); + }); + + it('returns 10 for aerialways', function() { + expect(iD.Way({tags: { aerialway: 'cable_car' }}).layer()).to.equal(10); + }); + + it('returns 1 for bridges', function() { + expect(iD.Way({tags: { bridge: 'yes' }}).layer()).to.equal(1); + }); + + it('returns -1 for cuttings', function() { + expect(iD.Way({tags: { cutting: 'yes' }}).layer()).to.equal(-1); + }); + + it('returns -1 for tunnels', function() { + expect(iD.Way({tags: { tunnel: 'yes' }}).layer()).to.equal(-1); + }); + + it('returns -1 for waterways', function() { + expect(iD.Way({tags: { waterway: 'stream' }}).layer()).to.equal(-1); + }); + + it('returns -10 for pipelines', function() { + expect(iD.Way({tags: { man_made: 'pipeline' }}).layer()).to.equal(-10); + }); + + it('returns -10 for boundaries', function() { + expect(iD.Way({tags: { boundary: 'administrative' }}).layer()).to.equal(-10); + }); + + }); + describe('#isOneWay', function() { it('returns false when the way has no tags', function() { expect(iD.Way().isOneWay()).to.be.false;