mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-13 14:46:01 +00:00
Fix specs
This commit is contained in:
10
js/iD/Way.js
10
js/iD/Way.js
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user