mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Fixup tests
This commit is contained in:
@@ -24,7 +24,7 @@ iD.Connection = function(graph) {
|
||||
// <tag k="highway" v="unclassified"/>
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
<script type="text/javascript" src="../js/lib/underscore-min.js"></script>
|
||||
<script type="text/javascript" src="../js/lib/d3.v2.min.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/id.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Entity.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Util.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Node.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Relation.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/GeoJSON.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Way.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/format/GeoJSON.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/Connection.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/iD/graph/Graph.js"></script>
|
||||
<script type="text/javascript" src="../js/iD/graph/Way.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/renderer/markers.js"></script>
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/Util.js"></script>
|
||||
<script type="text/javascript" src="spec/Node.js"></script>
|
||||
<script type="text/javascript" src="spec/Entity.js"></script>
|
||||
<script type="text/javascript" src="spec/Relation.js"></script>
|
||||
<script type="text/javascript" src="spec/Way.js"></script>
|
||||
<script type="text/javascript" src="spec/Map.js"></script>
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
describe('Relation', function() {
|
||||
var rm;
|
||||
|
||||
beforeEach(function() {
|
||||
rm = new iD.Relation();
|
||||
});
|
||||
|
||||
it('is instantiated', function() {
|
||||
expect(rm).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user