diff --git a/package.json b/package.json index d0e5d9595..e5a92805b 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "jshint": "2.3.0", "mocha": "1", "mocha-phantomjs": "3", - "chai": "~1.4", + "chai": "~1.9.2", "sinon": "~1.6", "sinon-chai": "~2.3.1", "happen": "0.1.2", diff --git a/test/spec/core/history.js b/test/spec/core/history.js index 05660a3fa..f46907f21 100644 --- a/test/spec/core/history.js +++ b/test/spec/core/history.js @@ -240,8 +240,8 @@ describe("iD.History", function () { history.perform(iD.actions.DeleteNode('n3')); // deletion var json = JSON.parse(history.toJSON()); expect(json.version).to.eql(3); - expect(json.entities).to.eql([node_1, node2.update({tags: {k: 'v'}})]); - expect(json.baseEntities).to.eql([node2, node3]); + expect( _.isEqual(json.entities, [node_1, node2.update({tags: {k: 'v'}})]) ).to.be.ok; + expect( _.isEqual(json.baseEntities, [node2, node3]) ).to.be.ok; }); }); diff --git a/test/spec/core/node.js b/test/spec/core/node.js index 810da7b4e..dfaaf19d8 100644 --- a/test/spec/core/node.js +++ b/test/spec/core/node.js @@ -14,7 +14,7 @@ describe('iD.Node', function () { describe("#extent", function() { it("returns a point extent", function() { - expect(iD.Node({loc: [5, 10]}).extent()).to.eql([[5, 10], [5, 10]]); + expect(iD.Node({loc: [5, 10]}).extent().equals([[5, 10], [5, 10]])).to.be.ok; }); }); diff --git a/test/spec/core/relation.js b/test/spec/core/relation.js index 451a53321..4a617421b 100644 --- a/test/spec/core/relation.js +++ b/test/spec/core/relation.js @@ -33,7 +33,7 @@ describe('iD.Relation', function () { r = iD.Relation({members: [{id: a.id}, {id: b.id}]}), graph = iD.Graph([a, b, r]); - expect(r.extent(graph)).to.eql([[0, 0], [5, 10]]) + expect(r.extent(graph).equals([[0, 0], [5, 10]])).to.be.ok; }); it("returns the known extent of incomplete relations", function () { @@ -42,13 +42,13 @@ describe('iD.Relation', function () { r = iD.Relation({members: [{id: a.id}, {id: b.id}]}), graph = iD.Graph([a, r]); - expect(r.extent(graph)).to.eql([[0, 0], [0, 0]]) + expect(r.extent(graph).equals([[0, 0], [0, 0]])).to.be.ok; }); it("does not error on self-referencing relations", function () { var r = iD.Relation(); r = r.addMember({id: r.id}); - expect(r.extent(iD.Graph([r]))).to.eql(iD.geo.Extent()) + expect(r.extent(iD.Graph([r]))).to.eql(iD.geo.Extent()); }); }); diff --git a/test/spec/core/way.js b/test/spec/core/way.js index a551db1ce..0ff1a56fc 100644 --- a/test/spec/core/way.js +++ b/test/spec/core/way.js @@ -69,7 +69,7 @@ describe('iD.Way', function() { node2 = iD.Node({loc: [5, 10]}), way = iD.Way({nodes: [node1.id, node2.id]}), graph = iD.Graph([node1, node2, way]); - expect(way.extent(graph)).to.eql([[0, 0], [5, 10]]); + expect(way.extent(graph).equals([[0, 0], [5, 10]])).to.be.ok; }); }); diff --git a/test/spec/geo.js b/test/spec/geo.js index b0919e8ff..e3f5b22e7 100644 --- a/test/spec/geo.js +++ b/test/spec/geo.js @@ -35,7 +35,7 @@ describe('iD.geo', function() { var o = [0, 0], a = [-2, 0], b = [2, 0]; - expect(iD.geo.cross(o, a, b)).to.eql(0); + expect(iD.geo.cross(o, a, b)).to.equal(0); }); }); diff --git a/test/spec/geo/extent.js b/test/spec/geo/extent.js index c299f4279..1cbeba94d 100644 --- a/test/spec/geo/extent.js +++ b/test/spec/geo/extent.js @@ -1,31 +1,31 @@ describe("iD.geo.Extent", function () { describe("constructor", function () { it("defaults to infinitely empty extent", function () { - expect(iD.geo.Extent()).to.eql([[Infinity, Infinity], [-Infinity, -Infinity]]); + expect(iD.geo.Extent().equals([[Infinity, Infinity], [-Infinity, -Infinity]])).to.be.ok; }); it("constructs via a point", function () { var p = [0, 0]; - expect(iD.geo.Extent(p)).to.eql([p, p]); + expect(iD.geo.Extent(p).equals([p, p])).to.be.ok; }); it("constructs via two points", function () { var min = [0, 0], max = [5, 10]; - expect(iD.geo.Extent(min, max)).to.eql([min, max]); + expect(iD.geo.Extent(min, max).equals([min, max])).to.be.ok; }); it("constructs via an extent", function () { var min = [0, 0], max = [5, 10]; - expect(iD.geo.Extent([min, max])).to.eql([min, max]); + expect(iD.geo.Extent([min, max]).equals([min, max])).to.be.ok; }); it("constructs via an iD.geo.Extent", function () { var min = [0, 0], max = [5, 10], extent = iD.geo.Extent(min, max); - expect(iD.geo.Extent(extent)).to.equal(extent); + expect(iD.geo.Extent(extent).equals(extent)).to.be.ok; }); it("has length 2", function () { @@ -45,6 +45,16 @@ describe("iD.geo.Extent", function () { }); }); + describe("#equals", function () { + it("tests extent equality", function () { + var e1 = iD.geo.Extent([0, 0], [10, 10]), + e2 = iD.geo.Extent([0, 0], [10, 10]), + e3 = iD.geo.Extent([0, 0], [12, 12]); + expect(e1.equals(e2)).to.be.ok; + expect(e1.equals(e3)).to.be.not.ok; + }); + }); + describe("#center", function () { it("returns the center point", function () { expect(iD.geo.Extent([0, 0], [5, 10]).center()).to.eql([2.5, 5]); @@ -73,17 +83,17 @@ describe("iD.geo.Extent", function () { it("does not modify self", function () { var extent = iD.geo.Extent([0, 0], [0, 0]); extent.extend([1, 1]); - expect(extent).to.eql([[0, 0], [0, 0]]); + expect(extent.equals([[0, 0], [0, 0]])).to.be.ok; }); it("returns the minimal extent containing self and the given point", function () { - expect(iD.geo.Extent().extend([0, 0])).to.eql([[0, 0], [0, 0]]); - expect(iD.geo.Extent([0, 0], [0, 0]).extend([5, 10])).to.eql([[0, 0], [5, 10]]); + expect(iD.geo.Extent().extend([0, 0]).equals([[0, 0], [0, 0]])).to.be.ok; + expect(iD.geo.Extent([0, 0], [0, 0]).extend([5, 10]).equals([[0, 0], [5, 10]])).to.be.ok; }); it("returns the minimal extent containing self and the given extent", function () { - expect(iD.geo.Extent().extend([[0, 0], [5, 10]])).to.eql([[0, 0], [5, 10]]); - expect(iD.geo.Extent([0, 0], [0, 0]).extend([[4, -1], [5, 10]])).to.eql([[0, -1], [5, 10]]); + expect(iD.geo.Extent().extend([[0, 0], [5, 10]]).equals([[0, 0], [5, 10]])).to.be.ok; + expect(iD.geo.Extent([0, 0], [0, 0]).extend([[4, -1], [5, 10]]).equals([[0, -1], [5, 10]])).to.be.ok; }); });