mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 07:25:15 +02:00
Test getPrototype, use American spellings, fix test formatting.
* Stub Lasso test * Add cmd test
This commit is contained in:
+1
-1
@@ -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]))];
|
||||
};
|
||||
|
||||
@@ -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]]);
|
||||
|
||||
@@ -239,6 +239,7 @@
|
||||
<script src="spec/ui/modal.js"></script>
|
||||
<script src="spec/ui/flash.js"></script>
|
||||
<script src="spec/ui/confirm.js"></script>
|
||||
<script src="spec/ui/cmd.js"></script>
|
||||
|
||||
<script src="spec/connection.js"></script>
|
||||
<script src="spec/geo.js"></script>
|
||||
@@ -250,6 +251,7 @@
|
||||
<script src="spec/behavior/hash.js"></script>
|
||||
<script src="spec/behavior/hover.js"></script>
|
||||
<script src="spec/behavior/select.js"></script>
|
||||
<script src="spec/behavior/lasso.js"></script>
|
||||
|
||||
<script src="spec/modes/add_point.js"></script>
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
+11
-4
@@ -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' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user