Add history urls to osm service and more URL tests

This commit is contained in:
Bryan Housel
2017-06-30 00:52:05 -04:00
parent 92a057bf3c
commit b6c2645409
2 changed files with 44 additions and 1 deletions

View File

@@ -203,6 +203,11 @@ export default {
},
historyURL: function(entity) {
return urlroot + '/' + entity.type + '/' + entity.osmId() + '/history';
},
userURL: function(username) {
return urlroot + '/user/' + username;
},

View File

@@ -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');