bump chai to 1.9.2 and fix tests affected by change in equality testing

re #2388
This commit is contained in:
Bryan Housel
2014-10-26 13:26:26 -04:00
parent d5ecd5d52d
commit 1f544e883b
7 changed files with 29 additions and 19 deletions

View File

@@ -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",

View File

@@ -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;
});
});

View File

@@ -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;
});
});

View File

@@ -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());
});
});

View File

@@ -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;
});
});

View File

@@ -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);
});
});

View File

@@ -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;
});
});