mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
Fix tests
This commit is contained in:
@@ -26,6 +26,10 @@ iD.Map = function(context) {
|
||||
tail = iD.ui.Tail(),
|
||||
surface, layergroup;
|
||||
|
||||
function visibleEntities() {
|
||||
return context.intersects(map.extent());
|
||||
}
|
||||
|
||||
function map(selection) {
|
||||
context.history()
|
||||
.on('change.map', redraw);
|
||||
@@ -57,14 +61,14 @@ iD.Map = function(context) {
|
||||
surface.on('mouseover.vertices', function() {
|
||||
vertices.hover(d3.event.target.__data__);
|
||||
if (map.editable() && !isTransformed()) {
|
||||
surface.call(vertices, context.graph(), map.zoom());
|
||||
surface.call(vertices, context.graph(), visibleEntities(), map.zoom());
|
||||
}
|
||||
});
|
||||
|
||||
surface.on('mouseout.vertices', function() {
|
||||
vertices.hover(d3.event.relatedTarget && d3.event.relatedTarget.__data__);
|
||||
if (map.editable() && !isTransformed()) {
|
||||
surface.call(vertices, context.graph(), map.zoom());
|
||||
surface.call(vertices, context.graph(), visibleEntities(), map.zoom());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -122,7 +126,7 @@ iD.Map = function(context) {
|
||||
} else {
|
||||
surface
|
||||
.call(points, graph, all, filter)
|
||||
.call(vertices, graph, map.zoom())
|
||||
.call(vertices, graph, visibleEntities(), map.zoom())
|
||||
.call(lines, graph, all, filter, dimensions)
|
||||
.call(areas, graph, all, filter)
|
||||
.call(midpoints, graph, all, filter, extent)
|
||||
|
||||
@@ -8,7 +8,6 @@ iD.svg.Midpoints = function(projection, context) {
|
||||
if (entity.type !== 'way') continue;
|
||||
if (context.selection().indexOf(entity.id) < 0) continue;
|
||||
|
||||
|
||||
var nodes = graph.childNodes(entity);
|
||||
|
||||
// skip the last node because it is always repeated
|
||||
|
||||
@@ -58,9 +58,8 @@ iD.svg.Vertices = function(projection, context) {
|
||||
}).length > 1;
|
||||
}
|
||||
|
||||
function drawVertices(surface, graph, zoom) {
|
||||
function drawVertices(surface, graph, entities, zoom) {
|
||||
var visible = visibleVertices(),
|
||||
entities = context.intersects(context.map().extent()),
|
||||
vertices = [];
|
||||
|
||||
for (var i = 0; i < entities.length; i++) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
describe("iD.svg.Midpoints", function () {
|
||||
var surface,
|
||||
projection = Object,
|
||||
filter = d3.functor(true);
|
||||
filter = d3.functor(true),
|
||||
context;
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD();
|
||||
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
|
||||
.call(iD.svg.Surface(iD()));
|
||||
.call(iD.svg.Surface(context));
|
||||
});
|
||||
|
||||
it("finds the location of the midpoints", function () {
|
||||
@@ -15,9 +17,8 @@ describe("iD.svg.Midpoints", function () {
|
||||
graph = iD.Graph([a, b, line]),
|
||||
extent = iD.geo.Extent([0, 0], [100, 100]);
|
||||
|
||||
// If no vertices are drawn, no midpoints are drawn. This dependence needs to be removed
|
||||
surface.call(iD.svg.Vertices(projection), graph, [a], filter, 16);
|
||||
surface.call(iD.svg.Midpoints(projection), graph, [line], filter, extent);
|
||||
context.selection = function() { return [line.id]; };
|
||||
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
|
||||
|
||||
expect(surface.select('.midpoint').datum().loc).to.eql([25, 0]);
|
||||
});
|
||||
@@ -29,7 +30,8 @@ describe("iD.svg.Midpoints", function () {
|
||||
graph = iD.Graph([a, b, line]),
|
||||
extent = iD.geo.Extent([0, 0], [100, 100]);
|
||||
|
||||
surface.call(iD.svg.Midpoints(projection), graph, [line], filter, extent);
|
||||
context.selection = function() { return [line.id]; };
|
||||
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
|
||||
|
||||
expect(surface.selectAll('.midpoint')[0]).to.have.length(0);
|
||||
});
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
describe("iD.svg.Vertices", function () {
|
||||
var surface,
|
||||
projection = Object,
|
||||
filter = d3.functor(true),
|
||||
context;
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD();
|
||||
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
|
||||
.call(iD.svg.Surface(iD()));
|
||||
.call(iD.svg.Surface(context));
|
||||
});
|
||||
|
||||
it("adds tag classes", function () {
|
||||
@@ -15,7 +14,7 @@ describe("iD.svg.Vertices", function () {
|
||||
way = iD.Way({nodes: [node.id]}),
|
||||
graph = iD.Graph([node, way]);
|
||||
|
||||
surface.call(iD.svg.Vertices(projection, context), graph, [node], filter);
|
||||
surface.call(iD.svg.Vertices(projection, context), graph, [node], 17);
|
||||
|
||||
expect(surface.select('.vertex')).to.be.classed('tag-highway');
|
||||
expect(surface.select('.vertex')).to.be.classed('tag-highway-traffic_signals');
|
||||
@@ -27,7 +26,7 @@ describe("iD.svg.Vertices", function () {
|
||||
way2 = iD.Way({nodes: [node.id]}),
|
||||
graph = iD.Graph([node, way1, way2]);
|
||||
|
||||
surface.call(iD.svg.Vertices(projection, context), graph, [node], filter);
|
||||
surface.call(iD.svg.Vertices(projection, context), graph, [node], 17);
|
||||
|
||||
expect(surface.select('.vertex')).to.be.classed('shared');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user