diff --git a/js/iD/Connection.js b/js/iD/Connection.js
index 661ee07dc..fb28c2d3f 100755
--- a/js/iD/Connection.js
+++ b/js/iD/Connection.js
@@ -24,7 +24,7 @@ iD.Connection = function(graph) {
//
function getTags(obj) {
var tags = {}, tagelems = obj.getElementsByTagName('tag');
- for (var i = 0; i < tagelems.length; i++) {
+ for (var i = 0, l = tagelems.length; i < l; i++) {
var item = tagelems[i];
tags[item.attributes.k.nodeValue] = item.attributes.v.nodeValue;
}
diff --git a/js/iD/Util.js b/js/iD/Util.js
index c3dde3ebf..63f18adc0 100644
--- a/js/iD/Util.js
+++ b/js/iD/Util.js
@@ -3,8 +3,9 @@ iD.Util = {};
iD.Util._counters = {};
iD.Util.id = function(counter) {
+ counter = counter || 'default';
if (!iD.Util._counters[counter]) iD.Util._counters[counter] = 0;
- return iD.Util._counters[counter];
+ return iD.Util._counters[counter]--;
};
iD.Util.friendlyName = function(entity) {
diff --git a/test/index.html b/test/index.html
index 24c10d7d3..3b963eb5a 100644
--- a/test/index.html
+++ b/test/index.html
@@ -13,13 +13,13 @@
-
-
-
-
-
+
+
+
+
+
@@ -30,8 +30,6 @@
-
-
diff --git a/test/spec/GeoJSON.js b/test/spec/GeoJSON.js
index 1708a70b8..b60fff7d3 100644
--- a/test/spec/GeoJSON.js
+++ b/test/spec/GeoJSON.js
@@ -2,11 +2,10 @@ describe('GeoJSON', function() {
describe('#mapping', function() {
it('should be able to map a node to geojson', function() {
- var node = new iD.Node(10, 38, -77);
- expect(iD.GeoJSON.mapping(node).geometry.type).toEqual('Point');
+ expect(iD.GeoJSON.mapping({ type: 'node', lat: 38, lon: -77 }).geometry.type).toEqual('Point');
});
it('should be able to map a way to geojson', function() {
- var way = new iD.Way();
+ var way = { type: 'way', nodes: [] };
var gj = iD.GeoJSON.mapping(way);
expect(gj.type).toEqual('Feature');
expect(gj.geometry.type).toEqual('LineString');
diff --git a/test/spec/Map.js b/test/spec/Map.js
index 3032a98eb..93716e277 100644
--- a/test/spec/Map.js
+++ b/test/spec/Map.js
@@ -4,10 +4,7 @@ describe('Map', function() {
beforeEach(function() {
foo = document.body.appendChild(document.createElement('div'));
foo.id = 'foo';
- map = iD.Map({
- selector: '#foo',
- connection: iD.Connection()
- });
+ map = iD.Map(d3.select('#foo').node());
});
afterEach(function() {
diff --git a/test/spec/Node.js b/test/spec/Node.js
deleted file mode 100644
index f62e12681..000000000
--- a/test/spec/Node.js
+++ /dev/null
@@ -1,21 +0,0 @@
-describe('Node', function() {
- var node;
-
- beforeEach(function() {
- node = new iD.Node(10, 38, -77);
- });
-
- it('is a node entity', function() {
- expect(node.type).toEqual('node');
- });
-
- it('should be initialized with a proper ID, lat, and lon', function() {
- expect(node.id).toEqual(10);
- expect(node.lat).toEqual(38);
- expect(node.lon).toEqual(-77);
- });
-
- it('knows if it is within a bounding box', function() {
- expect(node.intersects([[-90, 90], [90, -90]])).toBeTruthy();
- });
-});
diff --git a/test/spec/Relation.js b/test/spec/Relation.js
deleted file mode 100644
index a64e4590b..000000000
--- a/test/spec/Relation.js
+++ /dev/null
@@ -1,11 +0,0 @@
-describe('Relation', function() {
- var rm;
-
- beforeEach(function() {
- rm = new iD.Relation();
- });
-
- it('is instantiated', function() {
- expect(rm).toBeTruthy();
- });
-});
diff --git a/test/spec/Way.js b/test/spec/Way.js
index 40662ab49..c41855f52 100644
--- a/test/spec/Way.js
+++ b/test/spec/Way.js
@@ -2,29 +2,13 @@ describe('Way', function() {
var way;
beforeEach(function() {
- way = new iD.Way();
- console.log(way);
+ way = { type: 'way', nodes: ['n1', 'n2'] };
});
- it('is a way', function() {
- expect(way.type).toEqual('way');
- });
-
- it('has zero nodes by default', function() {
- expect(way.children.length).toEqual(0);
- });
describe('#isClosed', function() {
- it('is closed by default', function() {
- expect(way.isClosed()).toEqual(true);
+ it('is not closed with two distinct nodes ', function() {
+ expect(iD.Way.isClosed(way)).toEqual(false);
});
});
-
- it('is a way when it has no nodes', function() {
- expect(way.isType('way')).toEqual(true);
- });
-
- it('is also an area when it has no nodes', function() {
- expect(way.isType('area')).toEqual(true);
- });
});