mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Fix tests
This commit is contained in:
@@ -6,7 +6,7 @@ describe("iD.svg.LineString", function () {
|
||||
graph = iD.Graph([a, b, way]),
|
||||
projection = Object;
|
||||
|
||||
expect(iD.svg.LineString(projection, graph)(way)).to.equal("M0,0L2,3");
|
||||
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal("M0,0L2,3");
|
||||
});
|
||||
|
||||
it("returns null for an entity with no nodes", function () {
|
||||
@@ -14,6 +14,6 @@ describe("iD.svg.LineString", function () {
|
||||
graph = iD.Graph([way]),
|
||||
projection = Object;
|
||||
|
||||
expect(iD.svg.LineString(projection, graph)(way)).to.be.null;
|
||||
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.be.null;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
describe("iD.svg.Lines", function () {
|
||||
var surface,
|
||||
projection = Object,
|
||||
filter = d3.functor(true);
|
||||
filter = d3.functor(true),
|
||||
dimensions = [10, 10];
|
||||
|
||||
beforeEach(function () {
|
||||
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
|
||||
@@ -9,42 +10,50 @@ describe("iD.svg.Lines", function () {
|
||||
});
|
||||
|
||||
it("adds way and area classes", function () {
|
||||
var line = iD.Way(),
|
||||
graph = iD.Graph([line]);
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [1, 1]}),
|
||||
line = iD.Way({nodes: [a.id, b.id]}),
|
||||
graph = iD.Graph([a, b, line]);
|
||||
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter);
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter, dimensions);
|
||||
|
||||
expect(surface.select('path')).to.be.classed('way');
|
||||
expect(surface.select('path')).to.be.classed('line');
|
||||
});
|
||||
|
||||
it("adds tag classes", function () {
|
||||
var line = iD.Way({tags: {highway: 'residential'}}),
|
||||
graph = iD.Graph([line]);
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [1, 1]}),
|
||||
line = iD.Way({nodes: [a.id, b.id], tags: {highway: 'residential'}}),
|
||||
graph = iD.Graph([a, b, line]);
|
||||
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter);
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter, dimensions);
|
||||
|
||||
expect(surface.select('.line')).to.be.classed('tag-highway');
|
||||
expect(surface.select('.line')).to.be.classed('tag-highway-residential');
|
||||
});
|
||||
|
||||
it("adds member classes", function () {
|
||||
var line = iD.Way(),
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [1, 1]}),
|
||||
line = iD.Way({nodes: [a.id, b.id]}),
|
||||
relation = iD.Relation({members: [{id: line.id}], tags: {type: 'route'}}),
|
||||
graph = iD.Graph([line, relation]);
|
||||
graph = iD.Graph([a, b, line, relation]);
|
||||
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter);
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter, dimensions);
|
||||
|
||||
expect(surface.select('.line')).to.be.classed('member');
|
||||
expect(surface.select('.line')).to.be.classed('member-type-route');
|
||||
});
|
||||
|
||||
it("adds stroke classes for the tags of the parent relation of multipolygon members", function() {
|
||||
var line = iD.Way(),
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [1, 1]}),
|
||||
line = iD.Way({nodes: [a.id, b.id]}),
|
||||
relation = iD.Relation({members: [{id: line.id}], tags: {type: 'multipolygon', natural: 'wood'}}),
|
||||
graph = iD.Graph([line, relation]);
|
||||
graph = iD.Graph([a, b, line, relation]);
|
||||
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter);
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter, dimensions);
|
||||
|
||||
expect(surface.select('.stroke')).to.be.classed('tag-natural-wood');
|
||||
});
|
||||
@@ -57,7 +66,7 @@ describe("iD.svg.Lines", function () {
|
||||
.append('path')
|
||||
.attr('class', 'other');
|
||||
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter);
|
||||
surface.call(iD.svg.Lines(projection), graph, [line], filter, dimensions);
|
||||
|
||||
expect(surface.selectAll('.other')[0].length).to.equal(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user