mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 17:14:04 +02:00
Expand util tests
This commit is contained in:
+3
-1
@@ -45,7 +45,9 @@ iD.util.tagText = function(entity) {
|
||||
iD.util.stringQs = function(str) {
|
||||
return str.split('&').reduce(function(obj, pair){
|
||||
var parts = pair.split('=');
|
||||
obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]);
|
||||
if (parts.length === 2) {
|
||||
obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]);
|
||||
}
|
||||
return obj;
|
||||
}, {});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,24 @@ describe('Util', function() {
|
||||
expect(iD.util.trueObj([])).to.eql({});
|
||||
});
|
||||
|
||||
it('#tagText', function() {
|
||||
expect(iD.util.tagText({})).to.eql('');
|
||||
expect(iD.util.tagText({tags:{foo:'bar'}})).to.eql('foo: bar');
|
||||
expect(iD.util.tagText({tags:{foo:'bar',two:'three'}})).to.eql('foo: bar\ntwo: three');
|
||||
});
|
||||
|
||||
it('#stringQs', function() {
|
||||
expect(iD.util.stringQs('foo=bar')).to.eql({foo: 'bar'});
|
||||
expect(iD.util.stringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
|
||||
expect(iD.util.stringQs('')).to.eql({});
|
||||
});
|
||||
|
||||
it('#qsString', function() {
|
||||
expect(iD.util.qsString({ foo: 'bar' })).to.eql('foo=bar');
|
||||
expect(iD.util.qsString({ foo: 'bar', one: 2 })).to.eql('foo=bar&one=2');
|
||||
expect(iD.util.qsString({})).to.eql('');
|
||||
});
|
||||
|
||||
it('#friendlyName', function() {
|
||||
expect(iD.util.friendlyName({ tags: { name: 'hi' }})).to.equal('hi');
|
||||
expect(iD.util.friendlyName({ tags: { highway: 'Route 5' }})).to.equal('Route 5');
|
||||
@@ -13,6 +31,12 @@ describe('Util', function() {
|
||||
});
|
||||
|
||||
describe('geo', function() {
|
||||
describe('#roundCoords', function() {
|
||||
expect(iD.util.geo.roundCoords([0.1, 1])).to.eql([0, 1]);
|
||||
expect(iD.util.geo.roundCoords([0, 1])).to.eql([0, 1]);
|
||||
expect(iD.util.geo.roundCoords([0, 1.1])).to.eql([0, 1]);
|
||||
});
|
||||
|
||||
describe('#interp', function() {
|
||||
it('interpolates halfway', function() {
|
||||
var a = [0, 0],
|
||||
|
||||
Reference in New Issue
Block a user