mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Improve svg and util test coverage
This commit is contained in:
@@ -9,6 +9,28 @@ describe("iD.svg.LineString", function () {
|
||||
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal("M0,0L2,3");
|
||||
});
|
||||
|
||||
describe('resampling', function() {
|
||||
it("resamples a linestring", function () {
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [10, 0]}),
|
||||
way = iD.Way({nodes: [a.id, b.id]}),
|
||||
graph = iD.Graph([a, b, way]),
|
||||
projection = Object;
|
||||
|
||||
expect(iD.svg.LineString(projection, graph, [10, 10], 2)(way)).to.equal('M0,0L2,0L4,0L6,0L8,0L10,0');
|
||||
});
|
||||
|
||||
it("does not resmample when no steps are possible", function () {
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [10, 0]}),
|
||||
way = iD.Way({nodes: [a.id, b.id]}),
|
||||
graph = iD.Graph([a, b, way]),
|
||||
projection = Object;
|
||||
|
||||
expect(iD.svg.LineString(projection, graph, [10, 10], 20)(way)).to.equal('M0,0L10,0');
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null for an entity with no nodes", function () {
|
||||
var way = iD.Way(),
|
||||
graph = iD.Graph([way]),
|
||||
|
||||
@@ -28,4 +28,23 @@ describe('iD.Util', function() {
|
||||
expect(iD.util.getPrototypeOf({})).to.eql({});
|
||||
expect(iD.util.getPrototypeOf(new a())).to.eql({ foo: 'foo' });
|
||||
});
|
||||
|
||||
describe('#asyncMap', function() {
|
||||
it('handles correct replies', function() {
|
||||
iD.util.asyncMap([1, 2, 3],
|
||||
function(d, c) { c(null, d * 2); },
|
||||
function(err, res) {
|
||||
expect(err).to.eql([null, null, null]);
|
||||
expect(res).to.eql([2, 4, 6]);
|
||||
});
|
||||
});
|
||||
it('handles errors', function() {
|
||||
iD.util.asyncMap([1, 2, 3],
|
||||
function(d, c) { c('whoops ' + d, null); },
|
||||
function(err, res) {
|
||||
expect(err).to.eql(['whoops 1', 'whoops 2', 'whoops 3']);
|
||||
expect(res).to.eql([null, null, null]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user