diff --git a/modules/services/osm.js b/modules/services/osm.js index b5013e4df..a395f85cd 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -203,6 +203,11 @@ export default { }, + historyURL: function(entity) { + return urlroot + '/' + entity.type + '/' + entity.osmId() + '/history'; + }, + + userURL: function(username) { return urlroot + '/user/' + username; }, diff --git a/test/spec/services/osm.js b/test/spec/services/osm.js index 4644b310b..259a0cc7d 100644 --- a/test/spec/services/osm.js +++ b/test/spec/services/osm.js @@ -39,12 +39,50 @@ describe('iD.serviceOsm', function () { expect(connection.changesetURL(2)).to.match(/^https:/); }); - describe('#changesetUrl', function() { + describe('#changesetURL', function() { it('provides a changeset url', function() { expect(connection.changesetURL(2)).to.eql('http://www.openstreetmap.org/changeset/2'); }); }); + describe('#changesetsURL', function() { + it('provides a local changesets url', function() { + var center = [-74.65, 40.65]; + var zoom = 17; + expect(connection.changesetsURL(center, zoom)).to.eql('http://www.openstreetmap.org/history#map=17/40.65000/-74.65000'); + }); + }); + + describe('#entityURL', function() { + it('provides an entity url for a node', function() { + var e = iD.Node({id: 'n1'}); + expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/node/1'); + }); + it('provides an entity url for a way', function() { + var e = iD.Way({id: 'w1'}); + expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/way/1'); + }); + it('provides an entity url for a relation', function() { + var e = iD.Relation({id: 'r1'}); + expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/relation/1'); + }); + }); + + describe('#historyURL', function() { + it('provides a history url for a node', function() { + var e = iD.Node({id: 'n1'}); + expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/node/1/history'); + }); + it('provides a history url for a way', function() { + var e = iD.Way({id: 'w1'}); + expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/way/1/history'); + }); + it('provides a history url for a relation', function() { + var e = iD.Relation({id: 'r1'}); + expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/relation/1/history'); + }); + }); + describe('#userURL', function() { it('provides a user url', function() { expect(connection.userURL('bob')).to.eql('http://www.openstreetmap.org/user/bob');