Fix specs

This commit is contained in:
Tom MacWright
2012-10-26 16:17:09 -04:00
parent 8cc179d807
commit 39e5548d15
3 changed files with 9 additions and 6 deletions

View File

@@ -22,8 +22,10 @@ iD.Way = function(connection, id, nodes, tags, loaded) {
this.nodes = [];
this.extent = {};
for (var i = 0; i < nodes.length; i++) {
this.addNode(nodes[i]);
if (nodes) {
for (var i = 0; i < nodes.length; i++) {
this.addNode(nodes[i]);
}
}
};
@@ -37,8 +39,8 @@ iD.Way.prototype = {
// JOSM: http://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/data/osm/Way.java#L466
isClosed: function() {
// summary: Is this a closed way (first and last nodes the same)?
return this.nodes.length > 1 &&
this.nodes[this.nodes.length - 1] === this.nodes[0];
if (!this.nodes.length) return true;
return this.nodes[this.nodes.length - 1] === this.nodes[0];
},
isType: function(type) {

View File

@@ -11,7 +11,6 @@
<!-- include source files here... -->
<script type="text/javascript" src="../js/lib/underscore-min.js"></script>
<script type="text/javascript" src="../js/lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../js/lib/d3.v2.min.js"></script>
<script type="text/javascript" src="../js/iD/Util.js"></script>
<script type="text/javascript" src="../js/iD/Node.js"></script>
@@ -20,6 +19,7 @@
<script type="text/javascript" src="../js/iD/Way.js"></script>
<script type="text/javascript" src="../js/iD/Connection.js"></script>
<script type="text/javascript" src="../js/iD/actions/UndoStack.js"></script>
<script type="text/javascript" src="../js/iD/ui/Inspector.js"></script>
<script type="text/javascript" src="../js/iD/Controller.js"></script>
<script type="text/javascript" src="../js/iD/renderer/Map.js"></script>

View File

@@ -3,6 +3,7 @@ describe('Way', function() {
beforeEach(function() {
way = new iD.Way();
console.log(way);
});
it('is a way', function() {
@@ -26,7 +27,7 @@ describe('Way', function() {
});
it('can provide geojson', function() {
var gj = way.toGeoJSON();
var gj = way.toGeoJSON();
expect(gj.type).toEqual('Feature');
expect(gj.geometry.type).toEqual('LineString');
});