diff --git a/js/id/geo.js b/js/id/geo.js index 0b91c1ac4..e227c21c4 100644 --- a/js/id/geo.js +++ b/js/id/geo.js @@ -86,6 +86,6 @@ iD.geo.pathLength = function(path) { return length; }; -iD.geo.metresToCoordinates = function(loc, vector) { +iD.geo.metersToCoordinates = function(loc, vector) { return [vector[1] / 111200, vector[0] / 111200 / Math.abs(Math.cos(loc[1]))]; }; diff --git a/js/id/ui/preset/address.js b/js/id/ui/preset/address.js index 57cf1a89a..b351aea40 100644 --- a/js/id/ui/preset/address.js +++ b/js/id/ui/preset/address.js @@ -7,7 +7,7 @@ iD.ui.preset.address = function(context) { var extent = entity.extent(context.graph()), l = extent.center(), - dist = iD.geo.metresToCoordinates(l, [200, 200]), + dist = iD.geo.metersToCoordinates(l, [200, 200]), box = iD.geo.Extent( [extent[0][0] - dist[0], extent[0][1] - dist[1]], [extent[1][0] + dist[0], extent[1][1] + dist[1]]); diff --git a/test/index.html b/test/index.html index b130897cf..f500d0b08 100644 --- a/test/index.html +++ b/test/index.html @@ -239,6 +239,7 @@ + @@ -250,6 +251,7 @@ + diff --git a/test/spec/behavior/lasso.js b/test/spec/behavior/lasso.js new file mode 100644 index 000000000..bf92f04d9 --- /dev/null +++ b/test/spec/behavior/lasso.js @@ -0,0 +1,23 @@ +describe("iD.behavior.Lasso", function () { + var lasso, context; + + beforeEach(function () { + context = iD(); + + // Neuter connection + context.connection().loadTiles = function () {}; + + lasso = iD.behavior.Lasso(context); + + d3.select(document.createElement('div')) + .call(context.map()); + }); + + afterEach(function () { + lasso.off(context.surface()); + }); + + it('can be initialized', function () { + expect(context.surface().call(lasso)).to.be.ok; + }); +}); diff --git a/test/spec/connection.js b/test/spec/connection.js index 82cf6abc2..e286bb2bf 100644 --- a/test/spec/connection.js +++ b/test/spec/connection.js @@ -22,6 +22,24 @@ describe('iD.Connection', function () { expect(c.user()).to.equal(user); }); + describe('#changesetUrl', function() { + it('provides a changeset url', function() { + expect(c.changesetUrl(2)).to.eql('http://api06.dev.openstreetmap.org/browse/changeset/2'); + }); + }); + + describe('#userUrl', function() { + it('provides a user url', function() { + expect(c.userUrl('bob')).to.eql('http://api06.dev.openstreetmap.org/user/bob'); + }); + }); + + describe('#flush', function() { + it('flushes the connection', function() { + expect(c.flush()).to.eql(c); + }); + }); + describe('#loadFromURL', function () { it('loads test data', function (done) { c.loadFromURL('data/node.xml', done); diff --git a/test/spec/ui/cmd.js b/test/spec/ui/cmd.js new file mode 100644 index 000000000..c8350343f --- /dev/null +++ b/test/spec/ui/cmd.js @@ -0,0 +1,25 @@ +describe('iD.ui.cmd', function () { + var detect, os; + + beforeEach(function() { + detect = iD.detect; + iD.detect = function() { + return { os: os }; + }; + }); + + afterEach(function() { + iD.detect = detect; + }); + + it('does not overwrite mac keybindings', function () { + os = 'mac'; + expect(iD.ui.cmd('⌘a')).to.eql('⌘a'); + }); + + it('changes keys to linux versions', function () { + os = 'linux'; + expect(iD.ui.cmd('⌘a')).to.eql('Ctrl+a'); + expect(iD.ui.cmd('⇧a')).to.eql('Shift+a'); + }); +}); diff --git a/test/spec/util.js b/test/spec/util.js index d866a7b39..662416a0e 100644 --- a/test/spec/util.js +++ b/test/spec/util.js @@ -1,24 +1,31 @@ describe('iD.Util', function() { - it('.trueObj', function() { + it('#trueObj', function() { expect(iD.util.trueObj(['a', 'b', 'c'])).to.eql({ a: true, b: true, c: true }); expect(iD.util.trueObj([])).to.eql({}); }); - it('.tagText', function() { + 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, two=three'); }); - it('.stringQs', function() { + 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() { + 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('#getPrototypeOf', function() { + var a = function() {}; + a.prototype = { foo: 'foo' }; + expect(iD.util.getPrototypeOf({})).to.eql({}); + expect(iD.util.getPrototypeOf(new a())).to.eql({ foo: 'foo' }); + }); });