Fix tests and global leak

This commit is contained in:
Tom MacWright
2013-03-07 17:53:36 -05:00
parent 0fafa340fe
commit 3e69ef6f9e
6 changed files with 11 additions and 56 deletions

View File

@@ -41,7 +41,6 @@ data/data.js: \
js/lib/bootstrap-tooltip.js \
js/lib/d3.v3.js \
js/lib/d3.checkselect.js \
js/lib/d3.clip.js \
js/lib/d3.combobox.js \
js/lib/d3.geo.tile.js \
js/lib/d3.keybinding.js \

View File

@@ -24,6 +24,7 @@ iD.svg = {
var segments = [],
last,
next,
segment = [],
started = false,
d = '';

View File

@@ -29,7 +29,6 @@
<script src='../js/lib/d3.size.js'></script>
<script src='../js/lib/d3.trigger.js'></script>
<script src='../js/lib/d3.keybinding.js'></script>
<script src='../js/lib/d3.clip.js'></script>
<script src='../js/lib/d3.one.js'></script>
<script src='../js/lib/d3-compat.js'></script>
<script src='../js/lib/bootstrap-tooltip.js'></script>
@@ -185,7 +184,6 @@
<script src="spec/spec_helpers.js"></script>
<!-- include spec files here... -->
<script src="spec/lib/d3.clip.js"></script>
<script src="spec/lib/d3.keybinding.js"></script>
<script src="spec/lib/locale.js"></script>

View File

@@ -1,41 +0,0 @@
describe('d3.clip.cohenSutherland', function() {
var clip;
beforeEach(function() {
clip = d3.clip.cohenSutherland()
.bounds([0, 0, 10, 10]);
});
it('clips an empty array', function() {
expect(clip([])).to.eql([]);
});
it('clips a point inside bounds', function() {
expect(clip([[0, 0]])).to.eql([[[0, 0]]]);
});
it('clips a point outside bounds', function() {
expect(clip([[-1, -1]])).to.eql([]);
});
it('clips a single segment inside bounds', function() {
expect(clip([[0, 0], [10, 10]])).to.eql([[[0, 0], [10, 10]]]);
});
it('clips a single segment leaving bounds', function() {
expect(clip([[5, 5], [15, 15]])).to.eql([[[5, 5], [10, 10]]]);
});
it('clips a single segment entering bounds', function() {
expect(clip([[15, 15], [5, 5]])).to.eql([[[10, 10], [5, 5]]]);
});
it('clips a single segment entering and leaving bounds', function() {
expect(clip([[0, 15], [15, 0]])).to.eql([[[5, 10], [10, 5]]]);
});
it('clips multiple segments', function() {
expect(clip([[15, 15], [5, 5], [15, 15], [5, 5]])).to.
eql([[[10, 10], [5, 5], [10, 10]], [[10, 10], [5, 5]]]);
});
});

View File

@@ -1,12 +1,13 @@
describe("iD.svg.LineString", function () {
var projection = d3.geo.mercator();
it("returns an SVG path description for the entity's nodes", function () {
var a = iD.Node({loc: [0, 0]}),
b = iD.Node({loc: [2, 3]}),
way = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, way]),
projection = Object;
graph = iD.Graph([a, b, way]);
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal("M0,0L2,3");
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal('M480,250L482,245');
});
describe('resampling', function() {
@@ -14,27 +15,24 @@ describe("iD.svg.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;
graph = iD.Graph([a, b, way]);
expect(iD.svg.LineString(projection, graph, [10, 10], 2)(way)).to.equal('M0,0L2,0L4,0L6,0L8,0L10,0');
expect(iD.svg.LineString(projection, graph, [10, 10], 2)(way)).to.equal('M480,250L482,250L484,250L486,250L488,250L490,250L492,250L493,250');
});
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;
graph = iD.Graph([a, b, way]);
expect(iD.svg.LineString(projection, graph, [10, 10], 20)(way)).to.equal('M0,0L10,0');
expect(iD.svg.LineString(projection, graph, [10, 10], 20)(way)).to.equal('M480,250L493,250');
});
});
it("returns null for an entity with no nodes", function () {
var way = iD.Way(),
graph = iD.Graph([way]),
projection = Object;
graph = iD.Graph([way]);
expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.be.null;
});

View File

@@ -1,6 +1,6 @@
describe("iD.svg.Lines", function () {
var surface,
projection = Object,
projection = d3.geo.mercator(),
filter = d3.functor(true),
dimensions = [10, 10];