diff --git a/test/spec/core/connection.js b/test/spec/core/connection.js index 04f14355f..718707598 100644 --- a/test/spec/core/connection.js +++ b/test/spec/core/connection.js @@ -39,20 +39,20 @@ describe('iD.Connection', function () { }); }); - describe("#switch", function() { - it("changes the URL", function() { + describe('#switch', function() { + it('changes the URL', function() { c.switch({ - url: "http://example.com" + url: 'http://example.com' }); - expect(c.changesetURL(1)).to.equal("http://example.com/changeset/1") + expect(c.changesetURL(1)).to.equal('http://example.com/changeset/1'); }); - it("emits an auth event", function(done) { + it('emits an auth event', function(done) { c.on('auth', function() { done(); }); c.switch({ - url: "http://example.com" + url: 'http://example.com' }); }); }); @@ -111,8 +111,8 @@ describe('iD.Connection', function () { done(); }); - server.respondWith("GET", "http://www.openstreetmap.org/api/0.6/node/1", - [200, { "Content-Type": "text/xml" }, nodeXML]); + server.respondWith('GET', 'http://www.openstreetmap.org/api/0.6/node/1', + [200, { 'Content-Type': 'text/xml' }, nodeXML]); server.respond(); }); @@ -124,8 +124,8 @@ describe('iD.Connection', function () { done(); }); - server.respondWith("GET", "http://www.openstreetmap.org/api/0.6/way/1/full", - [200, { "Content-Type": "text/xml" }, wayXML]); + server.respondWith('GET', 'http://www.openstreetmap.org/api/0.6/way/1/full', + [200, { 'Content-Type': 'text/xml' }, wayXML]); server.respond(); }); }); @@ -155,8 +155,8 @@ describe('iD.Connection', function () { done(); }); - server.respondWith("GET", "http://www.openstreetmap.org/api/0.6/node/1/1", - [200, { "Content-Type": "text/xml" }, nodeXML]); + server.respondWith('GET', 'http://www.openstreetmap.org/api/0.6/node/1/1', + [200, { 'Content-Type': 'text/xml' }, nodeXML]); server.respond(); }); @@ -168,13 +168,14 @@ describe('iD.Connection', function () { done(); }); - server.respondWith("GET", "http://www.openstreetmap.org/api/0.6/way/1/1", - [200, { "Content-Type": "text/xml" }, wayXML]); + server.respondWith('GET', 'http://www.openstreetmap.org/api/0.6/way/1/1', + [200, { 'Content-Type': 'text/xml' }, wayXML]); server.respond(); }); }); describe('#loadMultiple', function () { + var server; beforeEach(function() { server = sinon.fakeServer.create(); }); @@ -211,7 +212,7 @@ describe('iD.Connection', function () { changes = {created: [r, w, n], modified: [], deleted: []}, jxon = c.osmChangeJXON('1234', changes); - expect(d3.entries(jxon.osmChange['create'])).to.eql([ + expect(d3.entries(jxon.osmChange.create)).to.eql([ {key: 'node', value: [n.asJXON('1234').node]}, {key: 'way', value: [w.asJXON('1234').way]}, {key: 'relation', value: [r.asJXON('1234').relation]} @@ -225,7 +226,7 @@ describe('iD.Connection', function () { changes = {created: [], modified: [r, w, n], deleted: []}, jxon = c.osmChangeJXON('1234', changes); - expect(jxon.osmChange['modify']).to.eql({ + expect(jxon.osmChange.modify).to.eql({ node: [n.asJXON('1234').node], way: [w.asJXON('1234').way], relation: [r.asJXON('1234').relation] @@ -239,7 +240,7 @@ describe('iD.Connection', function () { changes = {created: [], modified: [], deleted: [n, w, r]}, jxon = c.osmChangeJXON('1234', changes); - expect(d3.entries(jxon.osmChange['delete'])).to.eql([ + expect(d3.entries(jxon.osmChange.delete)).to.eql([ {key: 'relation', value: [r.asJXON('1234').relation]}, {key: 'way', value: [w.asJXON('1234').way]}, {key: 'node', value: [n.asJXON('1234').node]}, @@ -280,8 +281,8 @@ describe('iD.Connection', function () { done(); }); - server.respondWith("GET", "http://www.openstreetmap.org/api/0.6/changesets?user=1", - [200, { "Content-Type": "text/xml" }, changesetsXML]); + server.respondWith('GET', 'http://www.openstreetmap.org/api/0.6/changesets?user=1', + [200, { 'Content-Type': 'text/xml' }, changesetsXML]); server.respond(); }); }); @@ -289,6 +290,6 @@ describe('iD.Connection', function () { describe('#changesetTags', function() { it('omits comment when empty', function() { expect(c.changesetTags('', [])).not.to.have.property('comment'); - }) - }) + }); + }); }); diff --git a/test/spec/core/difference.js b/test/spec/core/difference.js index 3a51c4926..b3829127d 100644 --- a/test/spec/core/difference.js +++ b/test/spec/core/difference.js @@ -1,6 +1,6 @@ -describe("iD.Difference", function () { - describe("#changes", function () { - it("includes created entities", function () { +describe('iD.Difference', function () { + describe('#changes', function () { + it('includes created entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph(), head = base.replace(node), @@ -8,7 +8,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: undefined, head: node}}); }); - it("includes undone created entities", function () { + it('includes undone created entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph(), head = base.replace(node), @@ -16,7 +16,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: node, head: undefined}}); }); - it("includes modified entities", function () { + it('includes modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({ tags: { yes: 'no' } }), base = iD.Graph([n1]), @@ -25,7 +25,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: n1, head: n2}}); }); - it("includes undone modified entities", function () { + it('includes undone modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({ tags: { yes: 'no' } }), base = iD.Graph([n1]), @@ -34,7 +34,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: n2, head: n1}}); }); - it("doesn't include updated but identical entities", function () { + it('doesn\'t include updated but identical entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update(), base = iD.Graph([n1]), @@ -43,7 +43,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({}); }); - it("includes deleted entities", function () { + it('includes deleted entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node), @@ -51,7 +51,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: node, head: undefined}}); }); - it("includes undone deleted entities", function () { + it('includes undone deleted entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node), @@ -59,7 +59,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({n: {base: undefined, head: node}}); }); - it("doesn't include created entities that were subsequently deleted", function () { + it('doesn\'t include created entities that were subsequently deleted', function () { var node = iD.Node(), base = iD.Graph(), head = base.replace(node).remove(node), @@ -67,7 +67,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({}); }); - it("doesn't include created entities that were subsequently reverted", function () { + it('doesn\'t include created entities that were subsequently reverted', function () { var node = iD.Node({id: 'n-1'}), base = iD.Graph(), head = base.replace(node).revert('n-1'), @@ -75,7 +75,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({}); }); - it("doesn't include modified entities that were subsequently reverted", function () { + it('doesn\'t include modified entities that were subsequently reverted', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({ tags: { yes: 'no' } }), base = iD.Graph([n1]), @@ -84,7 +84,7 @@ describe("iD.Difference", function () { expect(diff.changes()).to.eql({}); }); - it("doesn't include deleted entities that were subsequently reverted", function () { + it('doesn\'t include deleted entities that were subsequently reverted', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node).revert('n'), @@ -93,8 +93,8 @@ describe("iD.Difference", function () { }); }); - describe("#extantIDs", function () { - it("includes the ids of created entities", function () { + describe('#extantIDs', function () { + it('includes the ids of created entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph(), head = base.replace(node), @@ -102,7 +102,7 @@ describe("iD.Difference", function () { expect(diff.extantIDs()).to.eql(['n']); }); - it("includes the ids of modified entities", function () { + it('includes the ids of modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), base = iD.Graph([n1]), @@ -111,7 +111,7 @@ describe("iD.Difference", function () { expect(diff.extantIDs()).to.eql(['n']); }); - it("omits the ids of deleted entities", function () { + it('omits the ids of deleted entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node), @@ -120,8 +120,8 @@ describe("iD.Difference", function () { }); }); - describe("#created", function () { - it("returns an array of created entities", function () { + describe('#created', function () { + it('returns an array of created entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph(), head = base.replace(node), @@ -130,8 +130,8 @@ describe("iD.Difference", function () { }); }); - describe("#modified", function () { - it("returns an array of modified entities", function () { + describe('#modified', function () { + it('returns an array of modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), base = iD.Graph([n1]), @@ -141,8 +141,8 @@ describe("iD.Difference", function () { }); }); - describe("#deleted", function () { - it("returns an array of deleted entities", function () { + describe('#deleted', function () { + it('returns an array of deleted entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node), @@ -151,7 +151,7 @@ describe("iD.Difference", function () { }); }); - describe("#summary", function () { + describe('#summary', function () { var base = iD.Graph([ iD.Node({id: 'a', tags: {crossing: 'zebra'}}), iD.Node({id: 'b'}), @@ -159,7 +159,7 @@ describe("iD.Difference", function () { iD.Way({id: '-', nodes: ['a', 'b']}) ]); - it("reports a created way as created", function() { + it('reports a created way as created', function() { var way = iD.Way({id: '+'}), head = base.replace(way), diff = iD.Difference(base, head); @@ -171,7 +171,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a deleted way as deleted", function() { + it('reports a deleted way as deleted', function() { var way = base.entity('-'), head = base.remove(way), diff = iD.Difference(base, head); @@ -183,7 +183,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a modified way as modified", function() { + it('reports a modified way as modified', function() { var way = base.entity('-').mergeTags({highway: 'primary'}), head = base.replace(way), diff = iD.Difference(base, head); @@ -195,7 +195,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a way as modified when a member vertex is moved", function() { + it('reports a way as modified when a member vertex is moved', function() { var vertex = base.entity('b').move([0,3]), head = base.replace(vertex), diff = iD.Difference(base, head); @@ -207,7 +207,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a way as modified when a member vertex is added", function() { + it('reports a way as modified when a member vertex is added', function() { var vertex = iD.Node({id: 'c'}), way = base.entity('-').addNode('c'), head = base.replace(vertex).replace(way), @@ -220,7 +220,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a way as modified when a member vertex is removed", function() { + it('reports a way as modified when a member vertex is removed', function() { var way = base.entity('-').removeNode('b'), head = base.replace(way), diff = iD.Difference(base, head); @@ -232,7 +232,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a created way containing a moved vertex as being created", function() { + it('reports a created way containing a moved vertex as being created', function() { var vertex = base.entity('b').move([0,3]), way = iD.Way({id: '+', nodes: ['b']}), head = base.replace(way).replace(vertex), @@ -249,7 +249,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a created way with a created vertex as being created", function() { + it('reports a created way with a created vertex as being created', function() { var vertex = iD.Node({id: 'c'}), way = iD.Way({id: '+', nodes: ['c']}), head = base.replace(vertex).replace(way), @@ -262,7 +262,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a vertex as modified when it has tags and they are changed", function() { + it('reports a vertex as modified when it has tags and they are changed', function() { var vertex = base.entity('a').mergeTags({highway: 'traffic_signals'}), head = base.replace(vertex), diff = iD.Difference(base, head); @@ -274,7 +274,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a vertex as modified when it has tags and is moved", function() { + it('reports a vertex as modified when it has tags and is moved', function() { var vertex = base.entity('a').move([1, 2]), head = base.replace(vertex), diff = iD.Difference(base, head); @@ -290,7 +290,7 @@ describe("iD.Difference", function () { }]); }); - it("does not report a vertex as modified when it is moved and has no-op tag changes", function() { + it('does not report a vertex as modified when it is moved and has no-op tag changes', function() { var vertex = base.entity('b').update({tags: {}, loc: [1, 2]}), head = base.replace(vertex), diff = iD.Difference(base, head); @@ -302,7 +302,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a vertex as deleted when it had tags", function() { + it('reports a vertex as deleted when it had tags', function() { var vertex = base.entity('v'), head = base.remove(vertex), diff = iD.Difference(base, head); @@ -314,7 +314,7 @@ describe("iD.Difference", function () { }]); }); - it("reports a vertex as created when it has tags", function() { + it('reports a vertex as created when it has tags', function() { var vertex = iD.Node({id: 'c', tags: {crossing: 'zebra'}}), way = base.entity('-').addNode('c'), head = base.replace(way).replace(vertex), @@ -332,25 +332,25 @@ describe("iD.Difference", function () { }); }); - describe("#complete", function () { - it("includes created entities", function () { + describe('#complete', function () { + it('includes created entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph(), head = base.replace(node), diff = iD.Difference(base, head); - expect(diff.complete()['n']).to.equal(node); + expect(diff.complete().n).to.equal(node); }); - it("includes modified entities", function () { + it('includes modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), base = iD.Graph([n1]), head = base.replace(n2), diff = iD.Difference(base, head); - expect(diff.complete()['n']).to.equal(n2); + expect(diff.complete().n).to.equal(n2); }); - it("includes deleted entities", function () { + it('includes deleted entities', function () { var node = iD.Node({id: 'n'}), base = iD.Graph([node]), head = base.remove(node), @@ -358,7 +358,7 @@ describe("iD.Difference", function () { expect(diff.complete()).to.eql({n: undefined}); }); - it("includes nodes added to a way", function () { + it('includes nodes added to a way', function () { var n1 = iD.Node({id: 'n1'}), n2 = iD.Node({id: 'n2'}), w1 = iD.Way({id: 'w', nodes: ['n1']}), @@ -367,10 +367,10 @@ describe("iD.Difference", function () { head = base.replace(w2), diff = iD.Difference(base, head); - expect(diff.complete()['n2']).to.equal(n2); + expect(diff.complete().n2).to.equal(n2); }); - it("includes nodes removed from a way", function () { + it('includes nodes removed from a way', function () { var n1 = iD.Node({id: 'n1'}), n2 = iD.Node({id: 'n2'}), w1 = iD.Way({id: 'w', nodes: ['n1', 'n2']}), @@ -379,10 +379,10 @@ describe("iD.Difference", function () { head = base.replace(w2), diff = iD.Difference(base, head); - expect(diff.complete()['n2']).to.equal(n2); + expect(diff.complete().n2).to.equal(n2); }); - it("includes parent ways of modified nodes", function () { + it('includes parent ways of modified nodes', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), way = iD.Way({id: 'w', nodes: ['n']}), @@ -390,10 +390,10 @@ describe("iD.Difference", function () { head = base.replace(n2), diff = iD.Difference(base, head); - expect(diff.complete()['w']).to.equal(way); + expect(diff.complete().w).to.equal(way); }); - it("includes parent relations of modified entities", function () { + it('includes parent relations of modified entities', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), rel = iD.Relation({id: 'r', members: [{id: 'n'}]}), @@ -401,10 +401,10 @@ describe("iD.Difference", function () { head = base.replace(n2), diff = iD.Difference(base, head); - expect(diff.complete()['r']).to.equal(rel); + expect(diff.complete().r).to.equal(rel); }); - it("includes parent relations of modified entities, recursively", function () { + it('includes parent relations of modified entities, recursively', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), rel1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}), @@ -413,10 +413,10 @@ describe("iD.Difference", function () { head = base.replace(n2), diff = iD.Difference(base, head); - expect(diff.complete()['r2']).to.equal(rel2); + expect(diff.complete().r2).to.equal(rel2); }); - it("includes parent relations of parent ways of modified nodes", function () { + it('includes parent relations of parent ways of modified nodes', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.move([1, 2]), way = iD.Way({id: 'w', nodes: ['n']}), @@ -425,10 +425,10 @@ describe("iD.Difference", function () { head = base.replace(n2), diff = iD.Difference(base, head); - expect(diff.complete()['r']).to.equal(rel); + expect(diff.complete().r).to.equal(rel); }); - it("copes with recursive relations", function () { + it('copes with recursive relations', function () { var node = iD.Node({id: 'n'}), rel1 = iD.Relation({id: 'r1', members: [{id: 'n'}, {id: 'r2'}]}), rel2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}), @@ -439,6 +439,6 @@ describe("iD.Difference", function () { expect(diff.complete()).to.be.ok; }); - it("limits changes to those within a given extent"); + it('limits changes to those within a given extent'); }); }); diff --git a/test/spec/core/entity.js b/test/spec/core/entity.js index 50012798f..03c308f1c 100644 --- a/test/spec/core/entity.js +++ b/test/spec/core/entity.js @@ -1,5 +1,5 @@ describe('iD.Entity', function () { - it("returns a subclass of the appropriate type", function () { + it('returns a subclass of the appropriate type', function () { expect(iD.Entity({type: 'node'})).be.an.instanceOf(iD.Node); expect(iD.Entity({type: 'way'})).be.an.instanceOf(iD.Way); expect(iD.Entity({type: 'relation'})).be.an.instanceOf(iD.Relation); @@ -9,42 +9,42 @@ describe('iD.Entity', function () { }); if (iD.debug) { - it("is frozen", function () { + it('is frozen', function () { expect(Object.isFrozen(iD.Entity())).to.be.true; }); - it("freezes tags", function () { + it('freezes tags', function () { expect(Object.isFrozen(iD.Entity().tags)).to.be.true; }); } - describe(".id", function () { - it("generates unique IDs", function () { + describe('.id', function () { + it('generates unique IDs', function () { expect(iD.Entity.id('node')).not.to.equal(iD.Entity.id('node')); }); - describe(".fromOSM", function () { - it("returns a ID string unique across entity types", function () { - expect(iD.Entity.id.fromOSM('node', '1')).to.equal("n1"); + describe('.fromOSM', function () { + it('returns a ID string unique across entity types', function () { + expect(iD.Entity.id.fromOSM('node', '1')).to.equal('n1'); }); }); - describe(".toOSM", function () { - it("reverses fromOSM", function () { + describe('.toOSM', function () { + it('reverses fromOSM', function () { expect(iD.Entity.id.toOSM(iD.Entity.id.fromOSM('node', '1'))).to.equal('1'); }); }); }); - describe("#copy", function () { - it("returns a new Entity", function () { + describe('#copy', function () { + it('returns a new Entity', function () { var n = iD.Entity({id: 'n'}), result = n.copy(null, {}); expect(result).to.be.an.instanceof(iD.Entity); expect(result).not.to.equal(n); }); - it("adds the new Entity to input object", function () { + it('adds the new Entity to input object', function () { var n = iD.Entity({id: 'n'}), copies = {}, result = n.copy(null, copies); @@ -52,7 +52,7 @@ describe('iD.Entity', function () { expect(copies.n).to.equal(result); }); - it("returns an existing copy in input object", function () { + it('returns an existing copy in input object', function () { var n = iD.Entity({id: 'n'}), copies = {}, result1 = n.copy(null, copies), @@ -61,7 +61,7 @@ describe('iD.Entity', function () { expect(result1).to.equal(result2); }); - it("resets 'id', 'user', and 'version' properties", function () { + it('resets \'id\', \'user\', and \'version\' properties', function () { var n = iD.Entity({id: 'n', version: 10, user: 'user'}), copies = {}; n.copy(null, copies); @@ -70,7 +70,7 @@ describe('iD.Entity', function () { expect(copies.n.user).to.be.undefined; }); - it("copies tags", function () { + it('copies tags', function () { var n = iD.Entity({id: 'n', tags: {foo: 'foo'}}), copies = {}; n.copy(null, copies); @@ -78,77 +78,77 @@ describe('iD.Entity', function () { }); }); - describe("#update", function () { - it("returns a new Entity", function () { + describe('#update', function () { + it('returns a new Entity', function () { var a = iD.Entity(), b = a.update({}); expect(b instanceof iD.Entity).to.be.true; expect(a).not.to.equal(b); }); - it("updates the specified attributes", function () { + it('updates the specified attributes', function () { var tags = {foo: 'bar'}, e = iD.Entity().update({tags: tags}); expect(e.tags).to.equal(tags); }); - it("preserves existing attributes", function () { + it('preserves existing attributes', function () { var e = iD.Entity({id: 'w1'}).update({}); expect(e.id).to.equal('w1'); }); - it("doesn't modify the input", function () { - var attrs = {tags: {foo: 'bar'}}, - e = iD.Entity().update(attrs); + it('doesn\'t modify the input', function () { + var attrs = {tags: {foo: 'bar'}}; + iD.Entity().update(attrs); expect(attrs).to.eql({tags: {foo: 'bar'}}); }); - it("doesn't copy prototype properties", function () { + it('doesn\'t copy prototype properties', function () { expect(iD.Entity().update({})).not.to.have.ownProperty('update'); }); - it("sets v to 1 if previously undefined", function() { + it('sets v to 1 if previously undefined', function() { expect(iD.Entity().update({}).v).to.equal(1); }); - it("increments v", function() { + it('increments v', function() { expect(iD.Entity({v: 1}).update({}).v).to.equal(2); }); }); - describe("#mergeTags", function () { - it("returns self if unchanged", function () { + describe('#mergeTags', function () { + it('returns self if unchanged', function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({a: 'a'}); expect(a).to.equal(b); }); - it("returns a new Entity if changed", function () { + it('returns a new Entity if changed', function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({a: 'b'}); expect(b instanceof iD.Entity).to.be.true; expect(a).not.to.equal(b); }); - it("merges tags", function () { + it('merges tags', function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({b: 'b'}); expect(b.tags).to.eql({a: 'a', b: 'b'}); }); - it("combines non-conflicting tags", function () { + it('combines non-conflicting tags', function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({a: 'a'}); expect(b.tags).to.eql({a: 'a'}); }); - it("combines conflicting tags with semicolons", function () { + it('combines conflicting tags with semicolons', function () { var a = iD.Entity({tags: {a: 'a'}}), b = a.mergeTags({a: 'b'}); expect(b.tags).to.eql({a: 'a;b'}); }); - it("combines combined tags", function () { + it('combines combined tags', function () { var a = iD.Entity({tags: {a: 'a;b'}}), b = iD.Entity({tags: {a: 'b'}}); @@ -156,7 +156,7 @@ describe('iD.Entity', function () { expect(b.mergeTags(a.tags).tags).to.eql({a: 'b;a'}); }); - it("combines combined tags with whitespace", function () { + it('combines combined tags with whitespace', function () { var a = iD.Entity({tags: {a: 'a; b'}}), b = iD.Entity({tags: {a: 'b'}}); @@ -165,23 +165,23 @@ describe('iD.Entity', function () { }); }); - describe("#osmId", function () { - it("returns an OSM ID as a string", function () { + describe('#osmId', function () { + it('returns an OSM ID as a string', function () { expect(iD.Entity({id: 'w1234'}).osmId()).to.eql('1234'); expect(iD.Entity({id: 'n1234'}).osmId()).to.eql('1234'); expect(iD.Entity({id: 'r1234'}).osmId()).to.eql('1234'); }); }); - describe("#intersects", function () { - it("returns true for a way with a node within the given extent", function () { + describe('#intersects', function () { + it('returns true for a way with a node within the given extent', function () { var node = iD.Node({loc: [0, 0]}), way = iD.Way({nodes: [node.id]}), graph = iD.Graph([node, way]); expect(way.intersects([[-5, -5], [5, 5]], graph)).to.equal(true); }); - it("returns false for way with no nodes within the given extent", function () { + it('returns false for way with no nodes within the given extent', function () { var node = iD.Node({loc: [6, 6]}), way = iD.Way({nodes: [node.id]}), graph = iD.Graph([node, way]); @@ -189,26 +189,26 @@ describe('iD.Entity', function () { }); }); - describe("#isUsed", function () { - it("returns false for an entity without tags", function () { + describe('#isUsed', function () { + it('returns false for an entity without tags', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(node.isUsed(graph)).to.equal(false); }); - it("returns true for an entity with tags", function () { + it('returns true for an entity with tags', function () { var node = iD.Node({tags: {foo: 'bar'}}), graph = iD.Graph([node]); expect(node.isUsed(graph)).to.equal(true); }); - it("returns false for an entity with only an area=yes tag", function () { + it('returns false for an entity with only an area=yes tag', function () { var node = iD.Node({tags: {area: 'yes'}}), graph = iD.Graph([node]); expect(node.isUsed(graph)).to.equal(false); }); - it("returns true for an entity that is a relation member", function () { + it('returns true for an entity that is a relation member', function () { var node = iD.Node(), relation = iD.Relation({members: [{id: node.id}]}), graph = iD.Graph([node, relation]); @@ -216,30 +216,30 @@ describe('iD.Entity', function () { }); }); - describe("#hasDeprecatedTags", function () { - it("returns false if entity has no tags", function () { + describe('#hasDeprecatedTags', function () { + it('returns false if entity has no tags', function () { expect(iD.Entity().deprecatedTags()).to.eql({}); }); - it("returns true if entity has deprecated tags", function () { + it('returns true if entity has deprecated tags', function () { expect(iD.Entity({ tags: { barrier: 'wire_fence' } }).deprecatedTags()).to.eql({ barrier: 'wire_fence' }); }); }); - describe("#hasInterestingTags", function () { - it("returns false if the entity has no tags", function () { + describe('#hasInterestingTags', function () { + it('returns false if the entity has no tags', function () { expect(iD.Entity().hasInterestingTags()).to.equal(false); }); - it("returns true if the entity has tags other than 'attribution', 'created_by', 'source', 'odbl' and tiger tags", function () { + it('returns true if the entity has tags other than \'attribution\', \'created_by\', \'source\', \'odbl\' and tiger tags', function () { expect(iD.Entity({tags: {foo: 'bar'}}).hasInterestingTags()).to.equal(true); }); - it("return false if the entity has only uninteresting tags", function () { + it('return false if the entity has only uninteresting tags', function () { expect(iD.Entity({tags: {source: 'Bing'}}).hasInterestingTags()).to.equal(false); }); - it("return false if the entity has only tiger tags", function () { + it('return false if the entity has only tiger tags', function () { expect(iD.Entity({tags: {'tiger:source': 'blah', 'tiger:foo': 'bar'}}).hasInterestingTags()).to.equal(false); }); }); diff --git a/test/spec/core/graph.js b/test/spec/core/graph.js index 46cb46a69..c1badeecc 100644 --- a/test/spec/core/graph.js +++ b/test/spec/core/graph.js @@ -1,65 +1,65 @@ describe('iD.Graph', function() { - describe("constructor", function () { - it("accepts an entities Array", function () { + describe('constructor', function () { + it('accepts an entities Array', function () { var entity = iD.Entity(), graph = iD.Graph([entity]); expect(graph.entity(entity.id)).to.equal(entity); }); - it("accepts a Graph", function () { + it('accepts a Graph', function () { var entity = iD.Entity(), graph = iD.Graph(iD.Graph([entity])); expect(graph.entity(entity.id)).to.equal(entity); }); - it("copies other's entities", function () { + it('copies other\'s entities', function () { var entity = iD.Entity(), base = iD.Graph([entity]), graph = iD.Graph(base); expect(graph.entities).not.to.equal(base.entities); }); - it("rebases on other's base", function () { + it('rebases on other\'s base', function () { var base = iD.Graph(), graph = iD.Graph(base); expect(graph.base().entities).to.equal(base.base().entities); }); - it("freezes by default", function () { + it('freezes by default', function () { expect(iD.Graph().frozen).to.be.true; }); - it("remains mutable if passed true as second argument", function () { + it('remains mutable if passed true as second argument', function () { expect(iD.Graph([], true).frozen).to.be.false; }); }); - describe("#hasEntity", function () { - it("returns the entity when present", function () { + describe('#hasEntity', function () { + it('returns the entity when present', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.hasEntity(node.id)).to.equal(node); }); - it("returns undefined when the entity is not present", function () { + it('returns undefined when the entity is not present', function () { expect(iD.Graph().hasEntity('1')).to.be.undefined; }); }); - describe("#entity", function () { - it("returns the entity when present", function () { + describe('#entity', function () { + it('returns the entity when present', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.entity(node.id)).to.equal(node); }); - it("throws when the entity is not present", function () { + it('throws when the entity is not present', function () { expect(function() { iD.Graph().entity('1'); }).to.throw; }); }); - describe("#rebase", function () { - it("preserves existing entities", function () { + describe('#rebase', function () { + it('preserves existing entities', function () { var node = iD.Node({id: 'n'}), graph = iD.Graph([node]); @@ -68,7 +68,7 @@ describe('iD.Graph', function() { expect(graph.entity('n')).to.equal(node); }); - it("includes new entities", function () { + it('includes new entities', function () { var node = iD.Node({id: 'n'}), graph = iD.Graph(); @@ -77,7 +77,7 @@ describe('iD.Graph', function() { expect(graph.entity('n')).to.equal(node); }); - it("doesn't rebase deleted entities", function () { + it('doesn\'t rebase deleted entities', function () { var node = iD.Node({id: 'n', visible: false}), graph = iD.Graph(); @@ -86,7 +86,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity('n')).to.be.not.ok; }); - it("gives precedence to existing entities", function () { + it('gives precedence to existing entities', function () { var a = iD.Node({id: 'n'}), b = iD.Node({id: 'n'}), graph = iD.Graph([a]); @@ -96,7 +96,7 @@ describe('iD.Graph', function() { expect(graph.entity('n')).to.equal(a); }); - it("gives precedence to new entities when force = true", function () { + it('gives precedence to new entities when force = true', function () { var a = iD.Node({id: 'n'}), b = iD.Node({id: 'n'}), graph = iD.Graph([a]); @@ -106,7 +106,7 @@ describe('iD.Graph', function() { expect(graph.entity('n')).to.equal(b); }); - it("inherits entities from base prototypally", function () { + it('inherits entities from base prototypally', function () { var graph = iD.Graph(); graph.rebase([iD.Node({id: 'n'})], [graph]); @@ -114,7 +114,7 @@ describe('iD.Graph', function() { expect(graph.entities).not.to.have.ownProperty('n'); }); - it("updates parentWays", function () { + it('updates parentWays', function () { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), w2 = iD.Way({id: 'w2', nodes: ['n']}), @@ -126,7 +126,7 @@ describe('iD.Graph', function() { expect(graph._parentWays.hasOwnProperty('n')).to.be.false; }); - it("avoids adding duplicate parentWays", function () { + it('avoids adding duplicate parentWays', function () { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), graph = iD.Graph([n, w1]); @@ -136,7 +136,7 @@ describe('iD.Graph', function() { expect(graph.parentWays(n)).to.eql([w1]); }); - it("updates parentWays for nodes with modified parentWays", function () { + it('updates parentWays for nodes with modified parentWays', function () { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), w2 = iD.Way({id: 'w2', nodes: ['n']}), @@ -149,7 +149,7 @@ describe('iD.Graph', function() { expect(graph2.parentWays(n)).to.eql([w1, w2, w3]); }); - it("avoids re-adding a modified way as a parent way", function() { + it('avoids re-adding a modified way as a parent way', function() { var n1 = iD.Node({id: 'n1'}), n2 = iD.Node({id: 'n2'}), w1 = iD.Way({id: 'w1', nodes: ['n1', 'n2']}), @@ -162,7 +162,7 @@ describe('iD.Graph', function() { expect(graph2.parentWays(n2)).to.eql([]); }); - it("avoids re-adding a deleted way as a parent way", function() { + it('avoids re-adding a deleted way as a parent way', function() { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), graph = iD.Graph([n, w1]), @@ -173,7 +173,7 @@ describe('iD.Graph', function() { expect(graph2.parentWays(n)).to.eql([]); }); - it("re-adds a deleted node that is discovered to have another parent", function() { + it('re-adds a deleted node that is discovered to have another parent', function() { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), w2 = iD.Way({id: 'w2', nodes: ['n']}), @@ -185,7 +185,7 @@ describe('iD.Graph', function() { expect(graph2.entity('n')).to.eql(n); }); - it("updates parentRelations", function () { + it('updates parentRelations', function () { var n = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}), r2 = iD.Relation({id: 'r2', members: [{id: 'n'}]}), @@ -197,7 +197,7 @@ describe('iD.Graph', function() { expect(graph._parentRels.hasOwnProperty('n')).to.be.false; }); - it("avoids re-adding a modified relation as a parent relation", function() { + it('avoids re-adding a modified relation as a parent relation', function() { var n = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}), r2 = r1.removeMembersWithID('n'), @@ -209,7 +209,7 @@ describe('iD.Graph', function() { expect(graph2.parentRelations(n)).to.eql([]); }); - it("avoids re-adding a deleted relation as a parent relation", function() { + it('avoids re-adding a deleted relation as a parent relation', function() { var n = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}), graph = iD.Graph([n, r1]), @@ -220,7 +220,7 @@ describe('iD.Graph', function() { expect(graph2.parentRelations(n)).to.eql([]); }); - it("updates parentRels for nodes with modified parentWays", function () { + it('updates parentRels for nodes with modified parentWays', function () { var n = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}), r2 = iD.Relation({id: 'r2', members: [{id: 'n'}]}), @@ -233,7 +233,7 @@ describe('iD.Graph', function() { expect(graph2.parentRelations(n)).to.eql([r1, r2, r3]); }); - it("invalidates transients", function() { + it('invalidates transients', function() { var n = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w1', nodes: ['n']}), w2 = iD.Way({id: 'w2', nodes: ['n']}), @@ -251,34 +251,34 @@ describe('iD.Graph', function() { }); }); - describe("#remove", function () { - it("returns a new graph", function () { + describe('#remove', function () { + it('returns a new graph', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.remove(node)).not.to.equal(graph); }); - it("doesn't modify the receiver", function () { + it('doesn\'t modify the receiver', function () { var node = iD.Node(), graph = iD.Graph([node]); graph.remove(node); expect(graph.entity(node.id)).to.equal(node); }); - it("removes the entity from the result", function () { + it('removes the entity from the result', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.remove(node).hasEntity(node.id)).to.be.undefined; }); - it("removes the entity as a parentWay", function () { + it('removes the entity as a parentWay', function () { var node = iD.Node({id: 'n' }), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph([node, w1]); expect(graph.remove(w1).parentWays(node)).to.eql([]); }); - it("removes the entity as a parentRelation", function () { + it('removes the entity as a parentRelation', function () { var node = iD.Node({id: 'n' }), r1 = iD.Relation({id: 'w', members: [{id: 'n' }]}), graph = iD.Graph([node, r1]); @@ -286,69 +286,69 @@ describe('iD.Graph', function() { }); }); - describe("#replace", function () { - it("is a no-op if the replacement is identical to the existing entity", function () { + describe('#replace', function () { + it('is a no-op if the replacement is identical to the existing entity', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.replace(node)).to.equal(graph); }); - it("returns a new graph", function () { + it('returns a new graph', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(graph.replace(node.update())).not.to.equal(graph); }); - it("doesn't modify the receiver", function () { + it('doesn\'t modify the receiver', function () { var node = iD.Node(), graph = iD.Graph([node]); graph.replace(node); expect(graph.entity(node.id)).to.equal(node); }); - it("replaces the entity in the result", function () { + it('replaces the entity in the result', function () { var node1 = iD.Node(), node2 = node1.update({}), graph = iD.Graph([node1]); expect(graph.replace(node2).entity(node2.id)).to.equal(node2); }); - it("adds parentWays", function () { + it('adds parentWays', function () { var node = iD.Node({id: 'n' }), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph([node]); expect(graph.replace(w1).parentWays(node)).to.eql([w1]); }); - it("removes parentWays", function () { + it('removes parentWays', function () { var node = iD.Node({id: 'n' }), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph([node, w1]); expect(graph.remove(w1).parentWays(node)).to.eql([]); }); - it("doesn't add duplicate parentWays", function () { + it('doesn\'t add duplicate parentWays', function () { var node = iD.Node({id: 'n' }), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph([node, w1]); expect(graph.replace(w1).parentWays(node)).to.eql([w1]); }); - it("adds parentRelations", function () { + it('adds parentRelations', function () { var node = iD.Node({id: 'n' }), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), graph = iD.Graph([node]); expect(graph.replace(r1).parentRelations(node)).to.eql([r1]); }); - it("removes parentRelations", function () { + it('removes parentRelations', function () { var node = iD.Node({id: 'n' }), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), graph = iD.Graph([node, r1]); expect(graph.remove(r1).parentRelations(node)).to.eql([]); }); - it("doesn't add duplicate parentRelations", function () { + it('doesn\'t add duplicate parentRelations', function () { var node = iD.Node({id: 'n' }), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), graph = iD.Graph([node, r1]); @@ -356,21 +356,21 @@ describe('iD.Graph', function() { }); }); - describe("#revert", function () { - it("is a no-op if the head entity is identical to the base entity", function () { + describe('#revert', function () { + it('is a no-op if the head entity is identical to the base entity', function () { var n1 = iD.Node({id: 'n'}), graph = iD.Graph([n1]); expect(graph.revert('n')).to.equal(graph); }); - it("returns a new graph", function () { + it('returns a new graph', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({}), graph = iD.Graph([n1]).replace(n2); expect(graph.revert('n')).not.to.equal(graph); }); - it("doesn't modify the receiver", function () { + it('doesn\'t modify the receiver', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({}), graph = iD.Graph([n1]).replace(n2); @@ -378,7 +378,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity('n')).to.equal(n2); }); - it("removes a new entity", function () { + it('removes a new entity', function () { var n1 = iD.Node({id: 'n'}), graph = iD.Graph().replace(n1); @@ -386,7 +386,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity('n')).to.be.undefined; }); - it("reverts an updated entity to the base version", function () { + it('reverts an updated entity to the base version', function () { var n1 = iD.Node({id: 'n'}), n2 = n1.update({}), graph = iD.Graph([n1]).replace(n2); @@ -395,7 +395,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity('n')).to.equal(n1); }); - it("restores a deleted entity", function () { + it('restores a deleted entity', function () { var n1 = iD.Node({id: 'n'}), graph = iD.Graph([n1]).remove(n1); @@ -403,7 +403,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity('n')).to.equal(n1); }); - it("removes new parentWays", function () { + it('removes new parentWays', function () { var n1 = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph().replace(n1).replace(w1); @@ -413,7 +413,7 @@ describe('iD.Graph', function() { expect(graph.parentWays(n1)).to.eql([]); }); - it("removes new parentRelations", function () { + it('removes new parentRelations', function () { var n1 = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), graph = iD.Graph().replace(n1).replace(r1); @@ -423,7 +423,7 @@ describe('iD.Graph', function() { expect(graph.parentRelations(n1)).to.eql([]); }); - it("reverts updated parentWays", function () { + it('reverts updated parentWays', function () { var n1 = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w', nodes: ['n']}), w2 = w1.removeNode('n'), @@ -434,7 +434,7 @@ describe('iD.Graph', function() { expect(graph.parentWays(n1)).to.eql([w1]); }); - it("reverts updated parentRelations", function () { + it('reverts updated parentRelations', function () { var n1 = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), r2 = r1.removeMembersWithID('n'), @@ -445,7 +445,7 @@ describe('iD.Graph', function() { expect(graph.parentRelations(n1)).to.eql([r1]); }); - it("restores deleted parentWays", function () { + it('restores deleted parentWays', function () { var n1 = iD.Node({id: 'n'}), w1 = iD.Way({id: 'w', nodes: ['n']}), graph = iD.Graph([n1, w1]).remove(w1); @@ -455,7 +455,7 @@ describe('iD.Graph', function() { expect(graph.parentWays(n1)).to.eql([w1]); }); - it("restores deleted parentRelations", function () { + it('restores deleted parentRelations', function () { var n1 = iD.Node({id: 'n'}), r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}), graph = iD.Graph([n1, r1]).remove(r1); @@ -466,18 +466,18 @@ describe('iD.Graph', function() { }); }); - describe("#update", function () { - it("returns a new graph if self is frozen", function () { + describe('#update', function () { + it('returns a new graph if self is frozen', function () { var graph = iD.Graph(); expect(graph.update()).not.to.equal(graph); }); - it("returns self if self is not frozen", function () { + it('returns self if self is not frozen', function () { var graph = iD.Graph([], true); expect(graph.update()).to.equal(graph); }); - it("doesn't modify self is self is frozen", function () { + it('doesn\'t modify self is self is frozen', function () { var node = iD.Node(), graph = iD.Graph([node]); @@ -486,7 +486,7 @@ describe('iD.Graph', function() { expect(graph.entity(node.id)).to.equal(node); }); - it("modifies self is self is not frozen", function () { + it('modifies self is self is not frozen', function () { var node = iD.Node(), graph = iD.Graph([node], true); @@ -495,7 +495,7 @@ describe('iD.Graph', function() { expect(graph.hasEntity(node.id)).to.be.undefined; }); - it("executes all of the given functions", function () { + it('executes all of the given functions', function () { var a = iD.Node(), b = iD.Node(), graph = iD.Graph([a]); @@ -510,31 +510,31 @@ describe('iD.Graph', function() { }); }); - describe("#parentWays", function() { - it("returns an array of ways that contain the given node id", function () { - var node = iD.Node({id: "n1"}), - way = iD.Way({id: "w1", nodes: ["n1"]}), + describe('#parentWays', function() { + it('returns an array of ways that contain the given node id', function () { + var node = iD.Node({id: 'n1'}), + way = iD.Way({id: 'w1', nodes: ['n1']}), graph = iD.Graph([node, way]); expect(graph.parentWays(node)).to.eql([way]); expect(graph.parentWays(way)).to.eql([]); }); }); - describe("#parentRelations", function() { - it("returns an array of relations that contain the given entity id", function () { - var node = iD.Node({id: "n1"}), - nonnode = iD.Node({id: "n2"}), - relation = iD.Relation({id: "r1", members: [{ id: "n1", role: 'from' }]}), + describe('#parentRelations', function() { + it('returns an array of relations that contain the given entity id', function () { + var node = iD.Node({id: 'n1'}), + nonnode = iD.Node({id: 'n2'}), + relation = iD.Relation({id: 'r1', members: [{ id: 'n1', role: 'from' }]}), graph = iD.Graph([node, relation]); expect(graph.parentRelations(node)).to.eql([relation]); expect(graph.parentRelations(nonnode)).to.eql([]); }); }); - describe("#childNodes", function () { - it("returns an array of child nodes", function () { - var node = iD.Node({id: "n1"}), - way = iD.Way({id: "w1", nodes: ["n1"]}), + describe('#childNodes', function () { + it('returns an array of child nodes', function () { + var node = iD.Node({id: 'n1'}), + way = iD.Way({id: 'w1', nodes: ['n1']}), graph = iD.Graph([node, way]); expect(graph.childNodes(way)).to.eql([node]); }); diff --git a/test/spec/core/history.js b/test/spec/core/history.js index 4bcd1d477..7e3ee1d32 100644 --- a/test/spec/core/history.js +++ b/test/spec/core/history.js @@ -1,4 +1,4 @@ -describe("iD.History", function () { +describe('iD.History', function () { var context, history, spy, action = function() { return iD.Graph(); }; @@ -10,20 +10,20 @@ describe("iD.History", function () { context.storage(history._getKey('lock'), null); }); - describe("#graph", function () { - it("returns the current graph", function () { + describe('#graph', function () { + it('returns the current graph', function () { expect(history.graph()).to.be.an.instanceOf(iD.Graph); }); }); - describe("#merge", function () { - it("merges the entities into all graph versions", function () { + describe('#merge', function () { + it('merges the entities into all graph versions', function () { var n = iD.Node({id: 'n'}); history.merge([n]); expect(history.graph().entity('n')).to.equal(n); }); - it("emits a change event with the specified extent", function () { + it('emits a change event with the specified extent', function () { var extent = {}; history.on('change', spy); history.merge([], extent); @@ -31,90 +31,90 @@ describe("iD.History", function () { }); }); - describe("#perform", function () { - it("returns a difference", function () { + describe('#perform', function () { + it('returns a difference', function () { expect(history.perform(action).changes()).to.eql({}); }); - it("updates the graph", function () { + it('updates the graph', function () { var node = iD.Node(); history.perform(function (graph) { return graph.replace(node); }); expect(history.graph().entity(node.id)).to.equal(node); }); - it("pushes an undo annotation", function () { - history.perform(action, "annotation"); - expect(history.undoAnnotation()).to.equal("annotation"); + it('pushes an undo annotation', function () { + history.perform(action, 'annotation'); + expect(history.undoAnnotation()).to.equal('annotation'); }); - it("emits a change event", function () { + it('emits a change event', function () { history.on('change', spy); var difference = history.perform(action); expect(spy).to.have.been.calledWith(difference); }); - it("performs multiple actions", function () { + it('performs multiple actions', function () { var action1 = sinon.stub().returns(iD.Graph()), action2 = sinon.stub().returns(iD.Graph()); - history.perform(action1, action2, "annotation"); + history.perform(action1, action2, 'annotation'); expect(action1).to.have.been.called; expect(action2).to.have.been.called; - expect(history.undoAnnotation()).to.equal("annotation"); + expect(history.undoAnnotation()).to.equal('annotation'); }); }); - describe("#replace", function () { - it("returns a difference", function () { + describe('#replace', function () { + it('returns a difference', function () { expect(history.replace(action).changes()).to.eql({}); }); - it("updates the graph", function () { + it('updates the graph', function () { var node = iD.Node(); history.replace(function (graph) { return graph.replace(node); }); expect(history.graph().entity(node.id)).to.equal(node); }); - it("replaces the undo annotation", function () { - history.perform(action, "annotation1"); - history.replace(action, "annotation2"); - expect(history.undoAnnotation()).to.equal("annotation2"); + it('replaces the undo annotation', function () { + history.perform(action, 'annotation1'); + history.replace(action, 'annotation2'); + expect(history.undoAnnotation()).to.equal('annotation2'); }); - it("emits a change event", function () { + it('emits a change event', function () { history.on('change', spy); var difference = history.replace(action); expect(spy).to.have.been.calledWith(difference); }); - it("performs multiple actions", function () { + it('performs multiple actions', function () { var action1 = sinon.stub().returns(iD.Graph()), action2 = sinon.stub().returns(iD.Graph()); - history.replace(action1, action2, "annotation"); + history.replace(action1, action2, 'annotation'); expect(action1).to.have.been.called; expect(action2).to.have.been.called; - expect(history.undoAnnotation()).to.equal("annotation"); + expect(history.undoAnnotation()).to.equal('annotation'); }); }); - describe("#pop", function () { - it("returns a difference", function () { - history.perform(action, "annotation"); + describe('#pop', function () { + it('returns a difference', function () { + history.perform(action, 'annotation'); expect(history.pop().changes()).to.eql({}); }); - it("updates the graph", function () { - history.perform(action, "annotation"); + it('updates the graph', function () { + history.perform(action, 'annotation'); history.pop(); expect(history.undoAnnotation()).to.be.undefined; }); - it("does not push the redo stack", function () { - history.perform(action, "annotation"); + it('does not push the redo stack', function () { + history.perform(action, 'annotation'); history.pop(); expect(history.redoAnnotation()).to.be.undefined; }); - it("emits a change event", function () { + it('emits a change event', function () { history.perform(action); history.on('change', spy); var difference = history.pop(); @@ -122,74 +122,74 @@ describe("iD.History", function () { }); }); - describe("#overwrite", function () { - it("returns a difference", function () { - history.perform(action, "annotation"); + describe('#overwrite', function () { + it('returns a difference', function () { + history.perform(action, 'annotation'); expect(history.overwrite(action).changes()).to.eql({}); }); - it("updates the graph", function () { - history.perform(action, "annotation"); + it('updates the graph', function () { + history.perform(action, 'annotation'); var node = iD.Node(); history.overwrite(function (graph) { return graph.replace(node); }); expect(history.graph().entity(node.id)).to.equal(node); }); - it("replaces the undo annotation", function () { - history.perform(action, "annotation1"); - history.overwrite(action, "annotation2"); - expect(history.undoAnnotation()).to.equal("annotation2"); + it('replaces the undo annotation', function () { + history.perform(action, 'annotation1'); + history.overwrite(action, 'annotation2'); + expect(history.undoAnnotation()).to.equal('annotation2'); }); - it("does not push the redo stack", function () { - history.perform(action, "annotation"); - history.overwrite(action, "annotation2"); + it('does not push the redo stack', function () { + history.perform(action, 'annotation'); + history.overwrite(action, 'annotation2'); expect(history.redoAnnotation()).to.be.undefined; }); - it("emits a change event", function () { - history.perform(action, "annotation"); + it('emits a change event', function () { + history.perform(action, 'annotation'); history.on('change', spy); - var difference = history.overwrite(action, "annotation2"); + var difference = history.overwrite(action, 'annotation2'); expect(spy).to.have.been.calledWith(difference); }); - it("performs multiple actions", function () { + it('performs multiple actions', function () { var action1 = sinon.stub().returns(iD.Graph()), action2 = sinon.stub().returns(iD.Graph()); - history.perform(action, "annotation"); - history.overwrite(action1, action2, "annotation2"); + history.perform(action, 'annotation'); + history.overwrite(action1, action2, 'annotation2'); expect(action1).to.have.been.called; expect(action2).to.have.been.called; - expect(history.undoAnnotation()).to.equal("annotation2"); + expect(history.undoAnnotation()).to.equal('annotation2'); }); }); - describe("#undo", function () { - it("returns a difference", function () { + describe('#undo', function () { + it('returns a difference', function () { expect(history.undo().changes()).to.eql({}); }); - it("pops the undo stack", function () { - history.perform(action, "annotation"); + it('pops the undo stack', function () { + history.perform(action, 'annotation'); history.undo(); expect(history.undoAnnotation()).to.be.undefined; }); - it("pushes the redo stack", function () { - history.perform(action, "annotation"); + it('pushes the redo stack', function () { + history.perform(action, 'annotation'); history.undo(); - expect(history.redoAnnotation()).to.equal("annotation"); + expect(history.redoAnnotation()).to.equal('annotation'); }); - it("emits an undone event", function () { + it('emits an undone event', function () { history.perform(action); history.on('undone', spy); history.undo(); expect(spy).to.have.been.called; }); - it("emits a change event", function () { + it('emits a change event', function () { history.perform(action); history.on('change', spy); var difference = history.undo(); @@ -197,12 +197,12 @@ describe("iD.History", function () { }); }); - describe("#redo", function () { - it("returns a difference", function () { + describe('#redo', function () { + it('returns a difference', function () { expect(history.redo().changes()).to.eql({}); }); - it("emits an redone event", function () { + it('emits an redone event', function () { history.perform(action); history.undo(); history.on('change', spy); @@ -210,7 +210,7 @@ describe("iD.History", function () { expect(spy).to.have.been.called; }); - it("emits a change event", function () { + it('emits a change event', function () { history.perform(action); history.undo(); history.on('change', spy); @@ -219,67 +219,67 @@ describe("iD.History", function () { }); }); - describe("#changes", function () { - it("includes created entities", function () { + describe('#changes', function () { + it('includes created entities', function () { var node = iD.Node(); history.perform(function (graph) { return graph.replace(node); }); expect(history.changes().created).to.eql([node]); }); - it("includes modified entities", function () { - var node1 = iD.Node({id: "n1"}), - node2 = node1.update({ tags: { yes: "no" } }); + it('includes modified entities', function () { + var node1 = iD.Node({id: 'n1'}), + node2 = node1.update({ tags: { yes: 'no' } }); history.merge([node1]); history.perform(function (graph) { return graph.replace(node2); }); expect(history.changes().modified).to.eql([node2]); }); - it("includes deleted entities", function () { - var node = iD.Node({id: "n1"}); + it('includes deleted entities', function () { + var node = iD.Node({id: 'n1'}); history.merge([node]); history.perform(function (graph) { return graph.remove(node); }); expect(history.changes().deleted).to.eql([node]); }); }); - describe("#hasChanges", function() { - it("is true when any of change's values are nonempty", function() { + describe('#hasChanges', function() { + it('is true when any of change\'s values are nonempty', function() { var node = iD.Node(); history.perform(function (graph) { return graph.replace(node); }); expect(history.hasChanges()).to.eql(true); }); - it("is false when all of change's values are empty", function() { + it('is false when all of change\'s values are empty', function() { expect(history.hasChanges()).to.eql(false); }); }); - describe("#reset", function () { - it("clears the version stack", function () { - history.perform(action, "annotation"); - history.perform(action, "annotation"); + describe('#reset', function () { + it('clears the version stack', function () { + history.perform(action, 'annotation'); + history.perform(action, 'annotation'); history.undo(); history.reset(); expect(history.undoAnnotation()).to.be.undefined; expect(history.redoAnnotation()).to.be.undefined; }); - it("emits a change event", function () { + it('emits a change event', function () { history.on('change', spy); history.reset(); expect(spy).to.have.been.called; }); }); - describe("#toJSON", function() { - it("doesn't generate unsaveable changes", function() { + describe('#toJSON', function() { + it('doesn\'t generate unsaveable changes', function() { var node_1 = iD.Node({id: 'n-1'}); history.perform(iD.actions.AddEntity(node_1)); history.perform(iD.actions.DeleteNode('n-1')); expect(history.toJSON()).to.be.not.ok; }); - it("generates v3 JSON", function() { + it('generates v3 JSON', function() { var node_1 = iD.Node({id: 'n-1'}), node1 = iD.Node({id: 'n1'}), node2 = iD.Node({id: 'n2'}), @@ -295,180 +295,180 @@ describe("iD.History", function () { }); }); - describe("#fromJSON", function() { - it("restores from v1 JSON (creation)", function() { + describe('#fromJSON', function() { + it('restores from v1 JSON (creation)', function() { var json = { - "stack": [ - {"entities": {}}, - {"entities": {"n-1": {"loc": [1, 2], "id": "n-1"}}, "imageryUsed": ["Bing"], "annotation": "Added a point."} + 'stack': [ + {'entities': {}}, + {'entities': {'n-1': {'loc': [1, 2], 'id': 'n-1'}}, 'imageryUsed': ['Bing'], 'annotation': 'Added a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 1 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]})); - expect(history.undoAnnotation()).to.eql("Added a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Added a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); }); - it("restores from v1 JSON (modification)", function() { + it('restores from v1 JSON (modification)', function() { var json = { - "stack": [ - {"entities": {}}, - {"entities": {"n-1": {"loc": [1, 2], "id": "n-1"}}, "imageryUsed": ["Bing"], "annotation": "Added a point."}, - {"entities": {"n-1": {"loc": [2, 3], "id": "n-1", "v": 1}}, "imageryUsed": ["Bing"], "annotation": "Moved a point."} + 'stack': [ + {'entities': {}}, + {'entities': {'n-1': {'loc': [1, 2], 'id': 'n-1'}}, 'imageryUsed': ['Bing'], 'annotation': 'Added a point.'}, + {'entities': {'n-1': {'loc': [2, 3], 'id': 'n-1', 'v': 1}}, 'imageryUsed': ['Bing'], 'annotation': 'Moved a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 2 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 2 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [2, 3], v: 1})); - expect(history.undoAnnotation()).to.eql("Moved a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Moved a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); }); - it("restores from v1 JSON (deletion)", function() { + it('restores from v1 JSON (deletion)', function() { var json = { - "stack": [ - {"entities": {}}, - {"entities": {"n1": "undefined"}, "imageryUsed": ["Bing"], "annotation": "Deleted a point."} + 'stack': [ + {'entities': {}}, + {'entities': {'n1': 'undefined'}, 'imageryUsed': ['Bing'], 'annotation': 'Deleted a point.'} ], - "nextIDs": {"node": -1, "way": -2, "relation": -3}, - "index": 1 + 'nextIDs': {'node': -1, 'way': -2, 'relation': -3}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); history.merge([iD.Node({id: 'n1'})]); expect(history.graph().hasEntity('n1')).to.be.undefined; - expect(history.undoAnnotation()).to.eql("Deleted a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Deleted a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -1, way: -2, relation: -3}); }); - it("restores from v2 JSON (creation)", function() { + it('restores from v2 JSON (creation)', function() { var json = { - "version": 2, - "entities": [ - {"loc": [1, 2], "id": "n-1"} + 'version': 2, + 'entities': [ + {'loc': [1, 2], 'id': 'n-1'} ], - "stack": [ + 'stack': [ {}, - {"modified": ["n-1v0"], "imageryUsed": ["Bing"], "annotation": "Added a point."} + {'modified': ['n-1v0'], 'imageryUsed': ['Bing'], 'annotation': 'Added a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 1 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]})); - expect(history.undoAnnotation()).to.eql("Added a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Added a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); expect(history.difference().created().length).to.eql(1); }); - it("restores from v2 JSON (modification)", function() { + it('restores from v2 JSON (modification)', function() { var json = { - "version": 2, - "entities": [ - {"loc": [2, 3], "id": "n1", "v": 1} + 'version': 2, + 'entities': [ + {'loc': [2, 3], 'id': 'n1', 'v': 1} ], - "stack": [ + 'stack': [ {}, - {"modified": ["n1v1"], "imageryUsed": ["Bing"], "annotation": "Moved a point."} + {'modified': ['n1v1'], 'imageryUsed': ['Bing'], 'annotation': 'Moved a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 1 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); history.merge([iD.Node({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135) expect(history.graph().entity('n1')).to.eql(iD.Node({id: 'n1', loc: [2, 3], v: 1})); - expect(history.undoAnnotation()).to.eql("Moved a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Moved a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); expect(history.difference().modified().length).to.eql(1); }); - it("restores from v2 JSON (deletion)", function() { + it('restores from v2 JSON (deletion)', function() { var json = { - "version": 2, - "entities": [], - "stack": [ + 'version': 2, + 'entities': [], + 'stack': [ {}, - {"deleted": ["n1"], "imageryUsed": ["Bing"], "annotation": "Deleted a point."} + {'deleted': ['n1'], 'imageryUsed': ['Bing'], 'annotation': 'Deleted a point.'} ], - "nextIDs": {"node": -1, "way": -2, "relation": -3}, - "index": 1 + 'nextIDs': {'node': -1, 'way': -2, 'relation': -3}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); history.merge([iD.Node({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135) expect(history.graph().hasEntity('n1')).to.be.undefined; - expect(history.undoAnnotation()).to.eql("Deleted a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Deleted a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -1, way: -2, relation: -3}); expect(history.difference().deleted().length).to.eql(1); }); - it("restores from v3 JSON (creation)", function() { + it('restores from v3 JSON (creation)', function() { var json = { - "version": 3, - "entities": [ - {"loc": [1, 2], "id": "n-1"} + 'version': 3, + 'entities': [ + {'loc': [1, 2], 'id': 'n-1'} ], - "baseEntities": [], - "stack": [ + 'baseEntities': [], + 'stack': [ {}, - {"modified": ["n-1v0"], "imageryUsed": ["Bing"], "annotation": "Added a point."} + {'modified': ['n-1v0'], 'imageryUsed': ['Bing'], 'annotation': 'Added a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 1 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]})); - expect(history.undoAnnotation()).to.eql("Added a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Added a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); expect(history.difference().created().length).to.eql(1); }); - it("restores from v3 JSON (modification)", function() { + it('restores from v3 JSON (modification)', function() { var json = { - "version": 3, - "entities": [ - {"loc": [2, 3], "id": "n1", "v": 1} + 'version': 3, + 'entities': [ + {'loc': [2, 3], 'id': 'n1', 'v': 1} ], - "baseEntities": [{"loc": [1, 2], "id": "n1"}], - "stack": [ + 'baseEntities': [{'loc': [1, 2], 'id': 'n1'}], + 'stack': [ {}, - {"modified": ["n1v1"], "imageryUsed": ["Bing"], "annotation": "Moved a point."} + {'modified': ['n1v1'], 'imageryUsed': ['Bing'], 'annotation': 'Moved a point.'} ], - "nextIDs": {"node": -2, "way": -1, "relation": -1}, - "index": 1 + 'nextIDs': {'node': -2, 'way': -1, 'relation': -1}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().entity('n1')).to.eql(iD.Node({id: 'n1', loc: [2, 3], v: 1})); - expect(history.undoAnnotation()).to.eql("Moved a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Moved a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1}); expect(history.difference().modified().length).to.eql(1); }); - it("restores from v3 JSON (deletion)", function() { + it('restores from v3 JSON (deletion)', function() { var json = { - "version": 3, - "entities": [], - "baseEntities": [{"loc": [1, 2], "id": "n1"}], - "stack": [ + 'version': 3, + 'entities': [], + 'baseEntities': [{'loc': [1, 2], 'id': 'n1'}], + 'stack': [ {}, - {"deleted": ["n1"], "imageryUsed": ["Bing"], "annotation": "Deleted a point."} + {'deleted': ['n1'], 'imageryUsed': ['Bing'], 'annotation': 'Deleted a point.'} ], - "nextIDs": {"node": -1, "way": -2, "relation": -3}, - "index": 1 + 'nextIDs': {'node': -1, 'way': -2, 'relation': -3}, + 'index': 1 }; history.fromJSON(JSON.stringify(json)); expect(history.graph().hasEntity('n1')).to.be.undefined; - expect(history.undoAnnotation()).to.eql("Deleted a point."); - expect(history.imageryUsed()).to.eql(["Bing"]); + expect(history.undoAnnotation()).to.eql('Deleted a point.'); + expect(history.imageryUsed()).to.eql(['Bing']); expect(iD.Entity.id.next).to.eql({node: -1, way: -2, relation: -3}); expect(history.difference().deleted().length).to.eql(1); }); diff --git a/test/spec/core/node.js b/test/spec/core/node.js index dfaaf19d8..24fd968bb 100644 --- a/test/spec/core/node.js +++ b/test/spec/core/node.js @@ -1,50 +1,50 @@ describe('iD.Node', function () { - it("returns a node", function () { + it('returns a node', function () { expect(iD.Node()).to.be.an.instanceOf(iD.Node); - expect(iD.Node().type).to.equal("node"); + expect(iD.Node().type).to.equal('node'); }); - it("defaults tags to an empty object", function () { + it('defaults tags to an empty object', function () { expect(iD.Node().tags).to.eql({}); }); - it("sets tags as specified", function () { + it('sets tags as specified', function () { expect(iD.Node({tags: {foo: 'bar'}}).tags).to.eql({foo: 'bar'}); }); - describe("#extent", function() { - it("returns a point extent", function() { + describe('#extent', function() { + it('returns a point extent', function() { expect(iD.Node({loc: [5, 10]}).extent().equals([[5, 10], [5, 10]])).to.be.ok; }); }); - describe("#intersects", function () { - it("returns true for a node within the given extent", function () { + describe('#intersects', function () { + it('returns true for a node within the given extent', function () { expect(iD.Node({loc: [0, 0]}).intersects([[-5, -5], [5, 5]])).to.equal(true); }); - it("returns false for a node outside the given extend", function () { + it('returns false for a node outside the given extend', function () { expect(iD.Node({loc: [6, 6]}).intersects([[-5, -5], [5, 5]])).to.equal(false); }); }); - describe("#geometry", function () { - it("returns 'vertex' if the node is a member of any way", function () { + describe('#geometry', function () { + it('returns \'vertex\' if the node is a member of any way', function () { var node = iD.Node(), way = iD.Way({nodes: [node.id]}), graph = iD.Graph([node, way]); expect(node.geometry(graph)).to.equal('vertex'); }); - it("returns 'point' if the node is not a member of any way", function () { + it('returns \'point\' if the node is not a member of any way', function () { var node = iD.Node(), graph = iD.Graph([node]); expect(node.geometry(graph)).to.equal('point'); }); }); - describe("#isIntersection", function () { - it("returns true for a node shared by more than one highway", function () { + describe('#isIntersection', function () { + it('returns true for a node shared by more than one highway', function () { var node = iD.Node(), w1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), w2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), @@ -52,7 +52,7 @@ describe('iD.Node', function () { expect(node.isIntersection(graph)).to.equal(true); }); - it("returns true for a node shared by more than one waterway", function () { + it('returns true for a node shared by more than one waterway', function () { var node = iD.Node(), w1 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}), w2 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}), @@ -61,8 +61,8 @@ describe('iD.Node', function () { }); }); - describe("#isHighwayIntersection", function () { - it("returns true for a node shared by more than one highway", function () { + describe('#isHighwayIntersection', function () { + it('returns true for a node shared by more than one highway', function () { var node = iD.Node(), w1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), w2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), @@ -70,7 +70,7 @@ describe('iD.Node', function () { expect(node.isHighwayIntersection(graph)).to.equal(true); }); - it("returns false for a node shared by more than one waterway", function () { + it('returns false for a node shared by more than one waterway', function () { var node = iD.Node(), w1 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}), w2 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}), @@ -79,7 +79,7 @@ describe('iD.Node', function () { }); }); - describe("#asJXON", function () { + describe('#asJXON', function () { it('converts a node to jxon', function() { var node = iD.Node({id: 'n-1', loc: [-77, 38], tags: {amenity: 'cafe'}}); expect(node.asJXON()).to.eql({node: { @@ -95,8 +95,8 @@ describe('iD.Node', function () { }); }); - describe("#asGeoJSON", function () { - it("converts to a GeoJSON Point geometry", function () { + describe('#asGeoJSON', function () { + it('converts to a GeoJSON Point geometry', function () { var node = iD.Node({tags: {amenity: 'cafe'}, loc: [1, 2]}), json = node.asGeoJSON(); diff --git a/test/spec/core/relation.js b/test/spec/core/relation.js index 1d30f32b0..34b8df795 100644 --- a/test/spec/core/relation.js +++ b/test/spec/core/relation.js @@ -1,33 +1,33 @@ describe('iD.Relation', function () { if (iD.debug) { - it("freezes nodes", function () { + it('freezes nodes', function () { expect(Object.isFrozen(iD.Relation().members)).to.be.true; }); } - it("returns a relation", function () { + it('returns a relation', function () { expect(iD.Relation()).to.be.an.instanceOf(iD.Relation); - expect(iD.Relation().type).to.equal("relation"); + expect(iD.Relation().type).to.equal('relation'); }); - it("defaults members to an empty array", function () { + it('defaults members to an empty array', function () { expect(iD.Relation().members).to.eql([]); }); - it("sets members as specified", function () { - expect(iD.Relation({members: ["n-1"]}).members).to.eql(["n-1"]); + it('sets members as specified', function () { + expect(iD.Relation({members: ['n-1']}).members).to.eql(['n-1']); }); - it("defaults tags to an empty object", function () { + it('defaults tags to an empty object', function () { expect(iD.Relation().tags).to.eql({}); }); - it("sets tags as specified", function () { + it('sets tags as specified', function () { expect(iD.Relation({tags: {foo: 'bar'}}).tags).to.eql({foo: 'bar'}); }); - describe("#copy", function () { - it("returns a new Relation", function () { + describe('#copy', function () { + it('returns a new Relation', function () { var r = iD.Relation({id: 'r'}), result = r.copy(null, {}); @@ -35,7 +35,7 @@ describe('iD.Relation', function () { expect(result).not.to.equal(r); }); - it("adds the new Relation to input object", function () { + it('adds the new Relation to input object', function () { var r = iD.Relation({id: 'r'}), copies = {}, result = r.copy(null, copies); @@ -43,7 +43,7 @@ describe('iD.Relation', function () { expect(copies.r).to.equal(result); }); - it("returns an existing copy in input object", function () { + it('returns an existing copy in input object', function () { var r = iD.Relation({id: 'r'}), copies = {}, result1 = r.copy(null, copies), @@ -52,14 +52,14 @@ describe('iD.Relation', function () { expect(result1).to.equal(result2); }); - it("deep copies members", function () { + it('deep copies members', function () { var a = iD.Node({id: 'a'}), b = iD.Node({id: 'b'}), c = iD.Node({id: 'c'}), w = iD.Way({id: 'w', nodes: ['a','b','c','a']}), r = iD.Relation({id: 'r', members: [{id: 'w', role: 'outer'}]}), graph = iD.Graph([a, b, c, w, r]), - copies = {} + copies = {}, result = r.copy(graph, copies); expect(Object.keys(copies)).to.have.length(5); @@ -71,7 +71,7 @@ describe('iD.Relation', function () { expect(result.members[0].role).to.equal(r.members[0].role); }); - it("deep copies non-tree relation graphs without duplicating children", function () { + it('deep copies non-tree relation graphs without duplicating children', function () { var w = iD.Way({id: 'w'}), r1 = iD.Relation({id: 'r1', members: [{id: 'r2'}, {id: 'w'}]}), r2 = iD.Relation({id: 'r2', members: [{id: 'w'}]}), @@ -88,7 +88,7 @@ describe('iD.Relation', function () { expect(copies.r2.members[0].id).to.equal(copies.w.id); }); - it("deep copies cyclical relation graphs without issue", function () { + it('deep copies cyclical relation graphs without issue', function () { var r1 = iD.Relation({id: 'r1', members: [{id: 'r2'}]}), r2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}), graph = iD.Graph([r1, r2]), @@ -100,7 +100,7 @@ describe('iD.Relation', function () { expect(copies.r2.members[0].id).to.equal(copies.r1.id); }); - it("deep copies self-referencing relations without issue", function () { + it('deep copies self-referencing relations without issue', function () { var r = iD.Relation({id: 'r', members: [{id: 'r'}]}), graph = iD.Graph([r]), copies = {}; @@ -111,8 +111,8 @@ describe('iD.Relation', function () { }); }); - describe("#extent", function () { - it("returns the minimal extent containing the extents of all members", function () { + describe('#extent', function () { + it('returns the minimal extent containing the extents of all members', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [5, 10]}), r = iD.Relation({members: [{id: a.id}, {id: b.id}]}), @@ -121,7 +121,7 @@ describe('iD.Relation', function () { expect(r.extent(graph).equals([[0, 0], [5, 10]])).to.be.ok; }); - it("returns the known extent of incomplete relations", function () { + it('returns the known extent of incomplete relations', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [5, 10]}), r = iD.Relation({members: [{id: a.id}, {id: b.id}]}), @@ -130,35 +130,35 @@ describe('iD.Relation', function () { expect(r.extent(graph).equals([[0, 0], [0, 0]])).to.be.ok; }); - it("does not error on self-referencing relations", function () { + 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()); }); }); - describe("#geometry", function () { - it("returns 'area' for multipolygons", function () { + describe('#geometry', function () { + it('returns \'area\' for multipolygons', function () { expect(iD.Relation({tags: {type: 'multipolygon'}}).geometry(iD.Graph())).to.equal('area'); }); - it("returns 'relation' for other relations", function () { + it('returns \'relation\' for other relations', function () { expect(iD.Relation().geometry(iD.Graph())).to.equal('relation'); }); }); - describe("#isDegenerate", function () { - it("returns true for a relation without members", function () { + describe('#isDegenerate', function () { + it('returns true for a relation without members', function () { expect(iD.Relation().isDegenerate()).to.equal(true); }); - it("returns false for a relation with members", function () { + it('returns false for a relation with members', function () { expect(iD.Relation({members: [{id: 'a', role: 'inner'}]}).isDegenerate()).to.equal(false); }); }); - describe("#memberByRole", function () { - it("returns the first member with the given role", function () { + describe('#memberByRole', function () { + it('returns the first member with the given role', function () { var r = iD.Relation({members: [ {id: 'a', role: 'inner'}, {id: 'b', role: 'outer'}, @@ -166,13 +166,13 @@ describe('iD.Relation', function () { expect(r.memberByRole('outer')).to.eql({id: 'b', role: 'outer', index: 1}); }); - it("returns undefined if no members have the given role", function () { + it('returns undefined if no members have the given role', function () { expect(iD.Relation().memberByRole('outer')).to.be.undefined; }); }); - describe("#memberById", function () { - it("returns the first member with the given id", function () { + describe('#memberById', function () { + it('returns the first member with the given id', function () { var r = iD.Relation({members: [ {id: 'a', role: 'outer'}, {id: 'b', role: 'outer'}, @@ -180,98 +180,98 @@ describe('iD.Relation', function () { expect(r.memberById('b')).to.eql({id: 'b', role: 'outer', index: 1}); }); - it("returns undefined if no members have the given role", function () { + it('returns undefined if no members have the given role', function () { expect(iD.Relation().memberById('b')).to.be.undefined; }); }); - describe("#isRestriction", function () { - it("returns true for 'restriction' type", function () { + describe('#isRestriction', function () { + it('returns true for \'restriction\' type', function () { expect(iD.Relation({tags: {type: 'restriction'}}).isRestriction()).to.be.true; }); - it("returns true for 'restriction:type' types", function () { + it('returns true for \'restriction:type\' types', function () { expect(iD.Relation({tags: {type: 'restriction:bus'}}).isRestriction()).to.be.true; }); - it("returns false otherwise", function () { + it('returns false otherwise', function () { expect(iD.Relation().isRestriction()).to.be.false; expect(iD.Relation({tags: {type: 'multipolygon'}}).isRestriction()).to.be.false; }); }); - describe("#indexedMembers", function () { - it("returns an array of members extended with indexes", function () { + describe('#indexedMembers', function () { + it('returns an array of members extended with indexes', function () { var r = iD.Relation({members: [{id: '1'}, {id: '3'}]}); expect(r.indexedMembers()).to.eql([{id: '1', index: 0}, {id: '3', index: 1}]); }); }); - describe("#addMember", function () { - it("adds a member at the end of the relation", function () { + describe('#addMember', function () { + it('adds a member at the end of the relation', function () { var r = iD.Relation(); expect(r.addMember({id: '1'}).members).to.eql([{id: '1'}]); }); - it("adds a member at index 0", function () { + it('adds a member at index 0', function () { var r = iD.Relation({members: [{id: '1'}]}); expect(r.addMember({id: '2'}, 0).members).to.eql([{id: '2'}, {id: '1'}]); }); - it("adds a member at a positive index", function () { + it('adds a member at a positive index', function () { var r = iD.Relation({members: [{id: '1'}, {id: '3'}]}); expect(r.addMember({id: '2'}, 1).members).to.eql([{id: '1'}, {id: '2'}, {id: '3'}]); }); - it("adds a member at a negative index", function () { + it('adds a member at a negative index', function () { var r = iD.Relation({members: [{id: '1'}, {id: '3'}]}); expect(r.addMember({id: '2'}, -1).members).to.eql([{id: '1'}, {id: '2'}, {id: '3'}]); }); }); - describe("#updateMember", function () { - it("updates the properties of the relation member at the specified index", function () { + describe('#updateMember', function () { + it('updates the properties of the relation member at the specified index', function () { var r = iD.Relation({members: [{role: 'forward'}]}); expect(r.updateMember({role: 'backward'}, 0).members).to.eql([{role: 'backward'}]); }); }); - describe("#removeMember", function () { - it("removes the member at the specified index", function () { + describe('#removeMember', function () { + it('removes the member at the specified index', function () { var r = iD.Relation({members: [{id: 'a'}, {id: 'b'}, {id: 'c'}]}); expect(r.removeMember(1).members).to.eql([{id: 'a'}, {id: 'c'}]); }); }); - describe("#removeMembersWithID", function () { - it("removes members with the given ID", function () { + describe('#removeMembersWithID', function () { + it('removes members with the given ID', function () { var r = iD.Relation({members: [{id: 'a'}, {id: 'b'}, {id: 'a'}]}); expect(r.removeMembersWithID('a').members).to.eql([{id: 'b'}]); }); }); - describe("#replaceMember", function () { - it("returns self if self does not contain needle", function () { + describe('#replaceMember', function () { + it('returns self if self does not contain needle', function () { var r = iD.Relation({members: []}); expect(r.replaceMember({id: 'a'}, {id: 'b'})).to.equal(r); }); - it("replaces a member which doesn't already exist", function () { + it('replaces a member which doesn\'t already exist', function () { var r = iD.Relation({members: [{id: 'a', role: 'a'}]}); expect(r.replaceMember({id: 'a'}, {id: 'b', type: 'node'}).members).to.eql([{id: 'b', role: 'a', type: 'node'}]); }); - it("preserves the existing role", function () { + it('preserves the existing role', function () { var r = iD.Relation({members: [{id: 'a', role: 'a', type: 'node'}]}); expect(r.replaceMember({id: 'a'}, {id: 'b', type: 'node'}).members).to.eql([{id: 'b', role: 'a', type: 'node'}]); }); - it("uses the replacement type", function () { + it('uses the replacement type', function () { var r = iD.Relation({members: [{id: 'a', role: 'a', type: 'node'}]}); expect(r.replaceMember({id: 'a'}, {id: 'b', type: 'way'}).members).to.eql([{id: 'b', role: 'a', type: 'way'}]); }); - it("removes members if replacing them would produce duplicates", function () { + it('removes members if replacing them would produce duplicates', function () { var r = iD.Relation({members: [ {id: 'a', role: 'b', type: 'node'}, {id: 'b', role: 'b', type: 'node'}]}); @@ -279,7 +279,7 @@ describe('iD.Relation', function () { }); }); - describe("#asJXON", function () { + describe('#asJXON', function () { it('converts a relation to jxon', function() { var relation = iD.Relation({id: 'r-1', members: [{id: 'w1', role: 'forward', type: 'way'}], tags: {type: 'route'}}); expect(relation.asJXON()).to.eql({relation: { @@ -294,7 +294,7 @@ describe('iD.Relation', function () { }); }); - describe("#asGeoJSON", function (){ + describe('#asGeoJSON', function (){ it('converts a multipolygon to a GeoJSON MultiPolygon geometry', function() { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), @@ -347,8 +347,8 @@ describe('iD.Relation', function () { }); }); - describe("#multipolygon", function () { - specify("single polygon consisting of a single way", function () { + describe('#multipolygon', function () { + specify('single polygon consisting of a single way', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -359,7 +359,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]); }); - specify("single polygon consisting of multiple ways", function () { + specify('single polygon consisting of multiple ways', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -371,7 +371,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]); }); - specify("single polygon consisting of multiple ways, one needing reversal", function () { + specify('single polygon consisting of multiple ways, one needing reversal', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -383,7 +383,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]); }); - specify("multiple polygons consisting of single ways", function () { + specify('multiple polygons consisting of single ways', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -398,7 +398,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]], [[d.loc, e.loc, f.loc, d.loc]]]); }); - specify("invalid geometry: unclosed ring consisting of a single way", function () { + specify('invalid geometry: unclosed ring consisting of a single way', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -409,7 +409,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc]]]); }); - specify("invalid geometry: unclosed ring consisting of multiple ways", function () { + specify('invalid geometry: unclosed ring consisting of multiple ways', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [3, 3]}), c = iD.Node({loc: [2, 2]}), @@ -421,7 +421,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc]]]); }); - specify("invalid geometry: unclosed ring consisting of multiple ways, alternate order", function () { + specify('invalid geometry: unclosed ring consisting of multiple ways, alternate order', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [2, 2]}), c = iD.Node({loc: [3, 3]}), @@ -434,7 +434,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]); }); - specify("invalid geometry: unclosed ring consisting of multiple ways, one needing reversal", function () { + specify('invalid geometry: unclosed ring consisting of multiple ways, one needing reversal', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [2, 2]}), c = iD.Node({loc: [3, 3]}), @@ -447,7 +447,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]); }); - specify("invalid geometry: unclosed ring consisting of multiple ways, one needing reversal, alternate order", function () { + specify('invalid geometry: unclosed ring consisting of multiple ways, one needing reversal, alternate order', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [2, 2]}), c = iD.Node({loc: [3, 3]}), @@ -460,7 +460,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]); }); - specify("single polygon with single single-way inner", function () { + specify('single polygon with single single-way inner', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [0, 1]}), c = iD.Node({loc: [1, 0]}), @@ -475,7 +475,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc], [d.loc, e.loc, f.loc, d.loc]]]); }); - specify("single polygon with single multi-way inner", function () { + specify('single polygon with single multi-way inner', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [0, 1]}), c = iD.Node({loc: [1, 0]}), @@ -494,7 +494,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(graph)).to.eql([[[a.loc, b.loc, c.loc, a.loc], [d.loc, e.loc, f.loc, d.loc]]]); }); - specify("single polygon with multiple single-way inners", function () { + specify('single polygon with multiple single-way inners', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [0, 1]}), c = iD.Node({loc: [1, 0]}), @@ -516,7 +516,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(graph)).to.eql([[[a.loc, b.loc, c.loc, a.loc], [d.loc, e.loc, f.loc, d.loc], [g.loc, h.loc, i.loc, g.loc]]]); }); - specify("multiple polygons with single single-way inner", function () { + specify('multiple polygons with single single-way inner', function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [0, 1]}), c = iD.Node({loc: [1, 0]}), @@ -538,7 +538,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(graph)).to.eql([[[a.loc, b.loc, c.loc, a.loc], [d.loc, e.loc, f.loc, d.loc]], [[g.loc, h.loc, i.loc, g.loc]]]); }); - specify("invalid geometry: unmatched inner", function () { + specify('invalid geometry: unmatched inner', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [2, 2]}), c = iD.Node({loc: [3, 3]}), @@ -549,7 +549,7 @@ describe('iD.Relation', function () { expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]); }); - specify("incomplete relation", function () { + specify('incomplete relation', function () { var a = iD.Node({loc: [1, 1]}), b = iD.Node({loc: [2, 2]}), c = iD.Node({loc: [3, 3]}), @@ -562,15 +562,15 @@ describe('iD.Relation', function () { }); }); - describe(".creationOrder comparator", function () { - specify("orders existing relations newest-first", function () { + describe('.creationOrder comparator', function () { + specify('orders existing relations newest-first', function () { var a = iD.Relation({ id: 'r1' }), b = iD.Relation({ id: 'r2' }); expect(iD.Relation.creationOrder(a, b)).to.be.above(0); expect(iD.Relation.creationOrder(b, a)).to.be.below(0); }); - specify("orders new relations newest-first", function () { + specify('orders new relations newest-first', function () { var a = iD.Relation({ id: 'r-1' }), b = iD.Relation({ id: 'r-2' }); expect(iD.Relation.creationOrder(a, b)).to.be.above(0); diff --git a/test/spec/core/tree.js b/test/spec/core/tree.js index 2176aa777..6d2e6ee20 100644 --- a/test/spec/core/tree.js +++ b/test/spec/core/tree.js @@ -1,6 +1,6 @@ -describe("iD.Tree", function() { - describe("#rebase", function() { - it("adds entities to the tree", function() { +describe('iD.Tree', function() { + describe('#rebase', function() { + it('adds entities to the tree', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}); @@ -11,7 +11,7 @@ describe("iD.Tree", function() { expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), graph)).to.eql([node]); }); - it("is idempotent", function() { + it('is idempotent', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -26,7 +26,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([node]); }); - it("does not insert if entity has a modified version", function() { + it('does not insert if entity has a modified version', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -42,7 +42,7 @@ describe("iD.Tree", function() { expect(tree.intersects(iD.geo.Extent([0, 0], [11, 11]), g)).to.eql([node_]); }); - it("does not error on self-referencing relations", function() { + it('does not error on self-referencing relations', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -57,7 +57,7 @@ describe("iD.Tree", function() { expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), graph)).to.eql([relation]); }); - it("adjusts entities that are force-rebased", function() { + it('adjusts entities that are force-rebased', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}); @@ -73,8 +73,8 @@ describe("iD.Tree", function() { }); }); - describe("#intersects", function() { - it("includes entities within extent, excludes those without", function() { + describe('#intersects', function() { + it('includes entities within extent, excludes those without', function() { var graph = iD.Graph(), tree = iD.Tree(graph), n1 = iD.Node({loc: [1, 1]}), @@ -85,7 +85,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([n1]); }); - it("includes intersecting relations after incomplete members are loaded", function() { + it('includes intersecting relations after incomplete members are loaded', function() { var graph = iD.Graph(), tree = iD.Tree(graph), n1 = iD.Node({id: 'n1', loc: [0, 0]}), @@ -103,7 +103,7 @@ describe("iD.Tree", function() { }); // This happens when local storage includes a changed way but not its nodes. - it("includes intersecting ways after missing nodes are loaded", function() { + it('includes intersecting ways after missing nodes are loaded', function() { var base = iD.Graph(), tree = iD.Tree(base), node = iD.Node({id: 'n', loc: [0.5, 0.5]}), @@ -118,7 +118,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([node, way]); }); - it("adjusts parent ways when a member node is moved", function() { + it('adjusts parent ways when a member node is moved', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -132,7 +132,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([]); }); - it("adjusts parent relations when a member node is moved", function() { + it('adjusts parent relations when a member node is moved', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -146,7 +146,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([]); }); - it("adjusts parent relations of parent ways when a member node is moved", function() { + it('adjusts parent relations of parent ways when a member node is moved', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -161,7 +161,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([]); }); - it("adjusts parent ways when a member node is removed", function() { + it('adjusts parent ways when a member node is removed', function() { var graph = iD.Graph(), tree = iD.Tree(graph), n1 = iD.Node({id: 'n1', loc: [1, 1]}), @@ -176,7 +176,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([n1]); }); - it("don't include parent way multiple times when multiple child nodes are moved", function() { + it('don\'t include parent way multiple times when multiple child nodes are moved', function() { // checks against the following regression: https://github.com/openstreetmap/iD/issues/1978 var graph = iD.Graph(), tree = iD.Tree(graph), @@ -196,7 +196,7 @@ describe("iD.Tree", function() { ); }); - it("doesn't include removed entities", function() { + it('doesn\'t include removed entities', function() { var graph = iD.Graph(), tree = iD.Tree(graph), node = iD.Node({loc: [1, 1]}), @@ -209,7 +209,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([]); }); - it("doesn't include removed entities after rebase", function() { + it('doesn\'t include removed entities after rebase', function() { var base = iD.Graph(), tree = iD.Tree(base), node = iD.Node({id: 'n', loc: [1, 1]}), @@ -223,7 +223,7 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([]); }); - it("handles recursive relations", function() { + it('handles recursive relations', function() { var base = iD.Graph(), tree = iD.Tree(base), node = iD.Node({id: 'n', loc: [1, 1]}), diff --git a/test/spec/core/way.js b/test/spec/core/way.js index 19118c1af..2e701e670 100644 --- a/test/spec/core/way.js +++ b/test/spec/core/way.js @@ -1,33 +1,33 @@ describe('iD.Way', function() { if (iD.debug) { - it("freezes nodes", function () { + it('freezes nodes', function () { expect(Object.isFrozen(iD.Way().nodes)).to.be.true; }); } - it("returns a way", function () { + it('returns a way', function () { expect(iD.Way()).to.be.an.instanceOf(iD.Way); - expect(iD.Way().type).to.equal("way"); + expect(iD.Way().type).to.equal('way'); }); - it("defaults nodes to an empty array", function () { + it('defaults nodes to an empty array', function () { expect(iD.Way().nodes).to.eql([]); }); - it("sets nodes as specified", function () { - expect(iD.Way({nodes: ["n-1"]}).nodes).to.eql(["n-1"]); + it('sets nodes as specified', function () { + expect(iD.Way({nodes: ['n-1']}).nodes).to.eql(['n-1']); }); - it("defaults tags to an empty object", function () { + it('defaults tags to an empty object', function () { expect(iD.Way().tags).to.eql({}); }); - it("sets tags as specified", function () { + it('sets tags as specified', function () { expect(iD.Way({tags: {foo: 'bar'}}).tags).to.eql({foo: 'bar'}); }); - describe("#copy", function () { - it("returns a new Way", function () { + describe('#copy', function () { + it('returns a new Way', function () { var w = iD.Way({id: 'w'}), result = w.copy(null, {}); @@ -35,7 +35,7 @@ describe('iD.Way', function() { expect(result).not.to.equal(w); }); - it("adds the new Way to input object", function () { + it('adds the new Way to input object', function () { var w = iD.Way({id: 'w'}), copies = {}, result = w.copy(null, copies); @@ -43,7 +43,7 @@ describe('iD.Way', function() { expect(copies.w).to.equal(result); }); - it("returns an existing copy in input object", function () { + it('returns an existing copy in input object', function () { var w = iD.Way({id: 'w'}), copies = {}, result1 = w.copy(null, copies), @@ -52,7 +52,7 @@ describe('iD.Way', function() { expect(result1).to.equal(result2); }); - it("deep copies nodes", function () { + it('deep copies nodes', function () { var a = iD.Node({id: 'a'}), b = iD.Node({id: 'b'}), w = iD.Way({id: 'w', nodes: ['a', 'b']}), @@ -68,7 +68,7 @@ describe('iD.Way', function() { expect(result.nodes).to.deep.eql([copies.a.id, copies.b.id]); }); - it("creates only one copy of shared nodes", function () { + it('creates only one copy of shared nodes', function () { var a = iD.Node({id: 'a'}), w = iD.Way({id: 'w', nodes: ['a', 'a']}), graph = iD.Graph([a, w]), @@ -79,45 +79,45 @@ describe('iD.Way', function() { }); }); - describe("#first", function () { - it("returns the first node", function () { + describe('#first', function () { + it('returns the first node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).first()).to.equal('a'); }); }); - describe("#last", function () { - it("returns the last node", function () { + describe('#last', function () { + it('returns the last node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).last()).to.equal('c'); }); }); - describe("#contains", function () { - it("returns true if the way contains the given node", function () { + describe('#contains', function () { + it('returns true if the way contains the given node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).contains('b')).to.be.true; }); - it("returns false if the way does not contain the given node", function () { + it('returns false if the way does not contain the given node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).contains('d')).to.be.false; }); }); - describe("#affix", function () { - it("returns 'prefix' if the way starts with the given node", function () { + describe('#affix', function () { + it('returns \'prefix\' if the way starts with the given node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).affix('a')).to.equal('prefix'); }); - it("returns 'suffix' if the way ends with the given node", function () { + it('returns \'suffix\' if the way ends with the given node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).affix('c')).to.equal('suffix'); }); - it("returns falsy if the way does not start or end with the given node", function () { + it('returns falsy if the way does not start or end with the given node', function () { expect(iD.Way({nodes: ['a', 'b', 'c']}).affix('b')).not.to.be.ok; expect(iD.Way({nodes: []}).affix('b')).not.to.be.ok; }); }); - describe("#extent", function () { - it("returns the minimal extent containing all member nodes", function () { + describe('#extent', function () { + it('returns the minimal extent containing all member nodes', function () { var node1 = iD.Node({loc: [0, 0]}), node2 = iD.Node({loc: [5, 10]}), way = iD.Way({nodes: [node1.id, node2.id]}), @@ -340,48 +340,48 @@ describe('iD.Way', function() { }); }); - describe("#isDegenerate", function() { - it("returns true for a linear way with zero or one nodes", function () { + describe('#isDegenerate', function() { + it('returns true for a linear way with zero or one nodes', function () { expect(iD.Way({nodes: []}).isDegenerate()).to.equal(true); expect(iD.Way({nodes: ['a']}).isDegenerate()).to.equal(true); }); - it("returns true for a circular way with only one unique node", function () { + it('returns true for a circular way with only one unique node', function () { expect(iD.Way({nodes: ['a', 'a']}).isDegenerate()).to.equal(true); }); - it("returns false for a linear way with two or more nodes", function () { + it('returns false for a linear way with two or more nodes', function () { expect(iD.Way({nodes: ['a', 'b']}).isDegenerate()).to.equal(false); }); - it("returns true for an area with zero, one, or two unique nodes", function () { + it('returns true for an area with zero, one, or two unique nodes', function () { expect(iD.Way({tags: {area: 'yes'}, nodes: []}).isDegenerate()).to.equal(true); expect(iD.Way({tags: {area: 'yes'}, nodes: ['a', 'a']}).isDegenerate()).to.equal(true); expect(iD.Way({tags: {area: 'yes'}, nodes: ['a', 'b', 'a']}).isDegenerate()).to.equal(true); }); - it("returns false for an area with three or more unique nodes", function () { + it('returns false for an area with three or more unique nodes', function () { expect(iD.Way({tags: {area: 'yes'}, nodes: ['a', 'b', 'c', 'a']}).isDegenerate()).to.equal(false); }); }); - describe("#areAdjacent", function() { - it("returns false for nodes not in the way", function() { + describe('#areAdjacent', function() { + it('returns false for nodes not in the way', function() { expect(iD.Way().areAdjacent('a', 'b')).to.equal(false); }); - it("returns false for non-adjacent nodes in the way", function() { + it('returns false for non-adjacent nodes in the way', function() { expect(iD.Way({nodes: ['a', 'b', 'c']}).areAdjacent('a', 'c')).to.equal(false); }); - it("returns true for adjacent nodes in the way (forward)", function() { + it('returns true for adjacent nodes in the way (forward)', function() { var way = iD.Way({nodes: ['a', 'b', 'c', 'd']}); expect(way.areAdjacent('a', 'b')).to.equal(true); expect(way.areAdjacent('b', 'c')).to.equal(true); expect(way.areAdjacent('c', 'd')).to.equal(true); }); - it("returns true for adjacent nodes in the way (reverse)", function() { + it('returns true for adjacent nodes in the way (reverse)', function() { var way = iD.Way({nodes: ['a', 'b', 'c', 'd']}); expect(way.areAdjacent('b', 'a')).to.equal(true); expect(way.areAdjacent('c', 'b')).to.equal(true); @@ -389,54 +389,54 @@ describe('iD.Way', function() { }); }); - describe("#geometry", function() { - it("returns 'line' when the way is not an area", function () { + describe('#geometry', function() { + it('returns \'line\' when the way is not an area', function () { expect(iD.Way().geometry(iD.Graph())).to.equal('line'); }); - it("returns 'area' when the way is an area", function () { + it('returns \'area\' when the way is an area', function () { expect(iD.Way({tags: { area: 'yes' }}).geometry(iD.Graph())).to.equal('area'); }); }); - describe("#addNode", function () { - it("adds a node to the end of a way", function () { + describe('#addNode', function () { + it('adds a node to the end of a way', function () { var w = iD.Way(); expect(w.addNode('a').nodes).to.eql(['a']); }); - it("adds a node to a way at index 0", function () { + it('adds a node to a way at index 0', function () { var w = iD.Way({nodes: ['a', 'b']}); expect(w.addNode('c', 0).nodes).to.eql(['c', 'a', 'b']); }); - it("adds a node to a way at a positive index", function () { + it('adds a node to a way at a positive index', function () { var w = iD.Way({nodes: ['a', 'b']}); expect(w.addNode('c', 1).nodes).to.eql(['a', 'c', 'b']); }); - it("adds a node to a way at a negative index", function () { + it('adds a node to a way at a negative index', function () { var w = iD.Way({nodes: ['a', 'b']}); expect(w.addNode('c', -1).nodes).to.eql(['a', 'c', 'b']); }); }); - describe("#updateNode", function () { - it("updates the node id at the specified index", function () { + describe('#updateNode', function () { + it('updates the node id at the specified index', function () { var w = iD.Way({nodes: ['a', 'b', 'c']}); expect(w.updateNode('d', 1).nodes).to.eql(['a', 'd', 'c']); }); }); - describe("#removeNode", function () { - it("removes the node", function () { + describe('#removeNode', function () { + it('removes the node', function () { var a = iD.Node({id: 'a'}), w = iD.Way({nodes: ['a']}); expect(w.removeNode('a').nodes).to.eql([]); }); - it("prevents duplicate consecutive nodes", function () { + it('prevents duplicate consecutive nodes', function () { var a = iD.Node({id: 'a'}), b = iD.Node({id: 'b'}), c = iD.Node({id: 'c'}), @@ -445,7 +445,7 @@ describe('iD.Way', function() { expect(w.removeNode('c').nodes).to.eql(['a', 'b']); }); - it("preserves circularity", function () { + it('preserves circularity', function () { var a = iD.Node({id: 'a'}), b = iD.Node({id: 'b'}), c = iD.Node({id: 'c'}), @@ -455,7 +455,7 @@ describe('iD.Way', function() { expect(w.removeNode('a').nodes).to.eql(['b', 'c', 'd', 'b']); }); - it("prevents duplicate consecutive nodes when preserving circularity", function () { + it('prevents duplicate consecutive nodes when preserving circularity', function () { var a = iD.Node({id: 'a'}), b = iD.Node({id: 'b'}), c = iD.Node({id: 'c'}), @@ -466,7 +466,7 @@ describe('iD.Way', function() { }); }); - describe("#asJXON", function () { + describe('#asJXON', function () { it('converts a way to jxon', function() { var node = iD.Way({id: 'w-1', nodes: ['n1', 'n2'], tags: {highway: 'residential'}}); expect(node.asJXON()).to.eql({way: { @@ -481,8 +481,8 @@ describe('iD.Way', function() { }); }); - describe("#asGeoJSON", function () { - it("converts a line to a GeoJSON LineString geometry", function () { + describe('#asGeoJSON', function () { + it('converts a line to a GeoJSON LineString geometry', function () { var a = iD.Node({loc: [1, 2]}), b = iD.Node({loc: [3, 4]}), w = iD.Way({tags: {highway: 'residential'}, nodes: [a.id, b.id]}), @@ -493,7 +493,7 @@ describe('iD.Way', function() { expect(json.coordinates).to.eql([a.loc, b.loc]); }); - it("converts an area to a GeoJSON Polygon geometry", function () { + it('converts an area to a GeoJSON Polygon geometry', function () { var a = iD.Node({loc: [1, 2]}), b = iD.Node({loc: [5, 6]}), c = iD.Node({loc: [3, 4]}), @@ -505,7 +505,7 @@ describe('iD.Way', function() { expect(json.coordinates).to.eql([[a.loc, b.loc, c.loc, a.loc]]); }); - it("converts an unclosed area to a GeoJSON LineString geometry", function () { + it('converts an unclosed area to a GeoJSON LineString geometry', function () { var a = iD.Node({loc: [1, 2]}), b = iD.Node({loc: [5, 6]}), c = iD.Node({loc: [3, 4]}), @@ -518,8 +518,8 @@ describe('iD.Way', function() { }); }); - describe("#area", function() { - it("returns a relative measure of area", function () { + describe('#area', function() { + it('returns a relative measure of area', function () { var graph = iD.Graph([ iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), @@ -539,7 +539,7 @@ describe('iD.Way', function() { expect(s).to.be.lt(l); }); - it("treats unclosed areas as if they were closed", function () { + it('treats unclosed areas as if they were closed', function () { var graph = iD.Graph([ iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), @@ -555,7 +555,7 @@ describe('iD.Way', function() { expect(s).to.equal(l); }); - it("returns 0 for degenerate areas", function () { + it('returns 0 for degenerate areas', function () { var graph = iD.Graph([ iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}),