diff --git a/test/spec/actions/add_member.js b/test/spec/actions/add_member.js index 1774f48df..dea678dc3 100644 --- a/test/spec/actions/add_member.js +++ b/test/spec/actions/add_member.js @@ -11,12 +11,12 @@ describe("iD.actions.AddMember", function() { } specify("no members", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - 'r': iD.Relation({id: 'r'}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Relation({id: 'r'}) + ]); graph = iD.actions.AddMember('r', {id: '-', type: 'way'})(graph); expect(members(graph)).to.eql(['-']); @@ -24,15 +24,15 @@ describe("iD.actions.AddMember", function() { specify("not connecting", function() { // a--->b c===>d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - 'c': iD.Node({id: 'c', loc: [0, 0]}), - 'd': iD.Node({id: 'd', loc: [0, 0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Node({id: 'c', loc: [0, 0]}), + iD.Node({id: 'd', loc: [0, 0]}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]}) + ]); graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph); expect(members(graph)).to.eql(['-', '=']); @@ -40,14 +40,14 @@ describe("iD.actions.AddMember", function() { specify("connecting at end", function() { // a--->b===>c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - 'c': iD.Node({id: 'c', loc: [0, 0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Node({id: 'c', loc: [0, 0]}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]}) + ]); graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph); expect(members(graph)).to.eql(['-', '=']); @@ -55,16 +55,16 @@ describe("iD.actions.AddMember", function() { specify("connecting at beginning", function() { // a===>b--->c~~~>d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - 'c': iD.Node({id: 'c', loc: [0, 0]}), - 'd': iD.Node({id: 'd', loc: [0, 0]}), - '=': iD.Way({id: '=', nodes: ['a', 'b']}), - '-': iD.Way({id: '-', nodes: ['b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Node({id: 'c', loc: [0, 0]}), + iD.Node({id: 'd', loc: [0, 0]}), + iD.Way({id: '=', nodes: ['a', 'b']}), + iD.Way({id: '-', nodes: ['b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) + ]); graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph); expect(members(graph)).to.eql(['=', '-', '~']); @@ -72,16 +72,16 @@ describe("iD.actions.AddMember", function() { specify("connecting in middle", function() { // a--->b===>c~~~>d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - 'c': iD.Node({id: 'c', loc: [0, 0]}), - 'd': iD.Node({id: 'd', loc: [0, 0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Node({id: 'c', loc: [0, 0]}), + iD.Node({id: 'd', loc: [0, 0]}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) + ]); graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph); expect(members(graph)).to.eql(['-', '=', '~']); diff --git a/test/spec/actions/circularize.js b/test/spec/actions/circularize.js index 282310796..559ec0c7b 100644 --- a/test/spec/actions/circularize.js +++ b/test/spec/actions/circularize.js @@ -2,13 +2,13 @@ describe("iD.actions.Circularize", function () { var projection = d3.geo.mercator(); it("creates nodes if necessary", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); graph = iD.actions.Circularize('-', projection)(graph); @@ -16,14 +16,14 @@ describe("iD.actions.Circularize", function () { }); it("reuses existing nodes", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - 'e': iD.Node({id: 'e', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Node({id: 'e', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) + ]), nodes; graph = iD.actions.Circularize('-', projection)(graph); @@ -37,14 +37,14 @@ describe("iD.actions.Circularize", function () { }); it("limits movement of nodes that are members of other ways", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [2, 2]}), - 'b': iD.Node({id: 'b', loc: [-2, 2]}), - 'c': iD.Node({id: 'c', loc: [-2, -2]}), - 'd': iD.Node({id: 'd', loc: [2, -2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}), - '=': iD.Way({id: '=', nodes: ['d']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [2, 2]}), + iD.Node({id: 'b', loc: [-2, 2]}), + iD.Node({id: 'c', loc: [-2, -2]}), + iD.Node({id: 'd', loc: [2, -2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}), + iD.Way({id: '=', nodes: ['d']}) + ]); graph = iD.actions.Circularize('-', projection)(graph); @@ -66,13 +66,13 @@ describe("iD.actions.Circularize", function () { } it("creates circle respecting min-angle limit", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]), centroid, points; graph = iD.actions.Circularize('-', projection, 20)(graph); @@ -91,13 +91,13 @@ describe("iD.actions.Circularize", function () { } it("leaves clockwise ways clockwise", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '+': iD.Way({id: '+', nodes: ['a', 'd', 'c', 'b', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '+', nodes: ['a', 'd', 'c', 'b', 'a']}) + ]); expect(area('+', graph)).to.be.gt(0); @@ -107,13 +107,13 @@ describe("iD.actions.Circularize", function () { }); it("leaves counter-clockwise ways counter-clockwise", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); expect(area('-', graph)).to.be.lt(0); diff --git a/test/spec/actions/connect.js b/test/spec/actions/connect.js index 06c7626f8..1bd7b0af0 100644 --- a/test/spec/actions/connect.js +++ b/test/spec/actions/connect.js @@ -1,10 +1,10 @@ describe("iD.actions.Connect", function() { it("removes all but the final node", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}) + ]); graph = iD.actions.Connect(['a', 'b', 'c'])(graph); @@ -28,15 +28,15 @@ describe("iD.actions.Connect", function() { // | // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - 'e': iD.Node({id: 'e'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'e']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Node({id: 'e'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'e']}) + ]); graph = iD.actions.Connect(['e', 'b'])(graph); @@ -53,15 +53,15 @@ describe("iD.actions.Connect", function() { // // Connect [a, d]. // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - 'e': iD.Node({id: 'e'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a']}), - '=': iD.Way({id: '=', nodes: ['d', 'e']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Node({id: 'e'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a']}), + iD.Way({id: '=', nodes: ['d', 'e']}) + ]); graph = iD.actions.Connect(['a', 'd'])(graph); @@ -77,12 +77,12 @@ describe("iD.actions.Connect", function() { // // a --- c // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}) + ]); graph = iD.actions.Connect(['b', 'c'])(graph); @@ -103,15 +103,14 @@ describe("iD.actions.Connect", function() { // | // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['b', 'd']}) - - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['b', 'd']}) + ]); graph = iD.actions.Connect(['b', 'c'])(graph); @@ -125,11 +124,11 @@ describe("iD.actions.Connect", function() { // // Connect [a, b] // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Way({id: '-', nodes: ['a', 'b']}) + ]); graph = iD.actions.Connect(['a', 'b'])(graph); @@ -138,11 +137,11 @@ describe("iD.actions.Connect", function() { }); it("merges tags to the surviving node", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', tags: {a: 'a'}}), - 'b': iD.Node({id: 'b', tags: {b: 'b'}}), - 'c': iD.Node({id: 'c', tags: {c: 'c'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', tags: {a: 'a'}}), + iD.Node({id: 'b', tags: {b: 'b'}}), + iD.Node({id: 'c', tags: {c: 'c'}}) + ]); graph = iD.actions.Connect(['a', 'b', 'c'])(graph); @@ -150,16 +149,16 @@ describe("iD.actions.Connect", function() { }); it("merges memberships to the surviving node", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'd']}), - 'r1': iD.Relation({id: 'r1', members: [{id: 'b', role: 'r1', type: 'node'}]}), - 'r2': iD.Relation({id: 'r2', members: [{id: 'b', role: 'r2', type: 'node'}, {id: 'c', role: 'r2', type: 'node'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'd']}), + iD.Relation({id: 'r1', members: [{id: 'b', role: 'r1', type: 'node'}]}), + iD.Relation({id: 'r2', members: [{id: 'b', role: 'r2', type: 'node'}, {id: 'c', role: 'r2', type: 'node'}]}) + ]); graph = iD.actions.Connect(['b', 'c'])(graph); diff --git a/test/spec/actions/disconnect.js b/test/spec/actions/disconnect.js index fab001edc..1c8873dfb 100644 --- a/test/spec/actions/disconnect.js +++ b/test/spec/actions/disconnect.js @@ -1,7 +1,7 @@ describe("iD.actions.Disconnect", function () { describe("#disabled", function () { it("returns 'not_connected' for a node shared by less than two ways", function () { - var graph = iD.Graph({'a': iD.Node()}); + var graph = iD.Graph([iD.Node({id: 'a'})]); expect(iD.actions.Disconnect('a').disabled(graph)).to.equal('not_connected'); }); @@ -10,13 +10,13 @@ describe("iD.actions.Disconnect", function () { // a ---- b // | | // d ---- c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - 'w': iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); expect(iD.actions.Disconnect('a').disabled(graph)).not.to.be.ok; }); @@ -24,28 +24,28 @@ describe("iD.actions.Disconnect", function () { // a ---- b ---- c // | // d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}) + ]); expect(iD.actions.Disconnect('b').disabled(graph)).not.to.be.ok; }); it("returns falsy for an intersection of two ways with parent way specified", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['*', 'd']}) + ]); expect(iD.actions.Disconnect('*', ['|']).disabled(graph)).not.to.be.ok; }); @@ -65,14 +65,14 @@ describe("iD.actions.Disconnect", function () { // | // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}) + ]); graph = iD.actions.Disconnect('b', 'e')(graph); @@ -92,15 +92,15 @@ describe("iD.actions.Disconnect", function () { // | // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}) + ]); graph = iD.actions.Disconnect('b', 'e').limitWays(['-'])(graph); @@ -118,12 +118,12 @@ describe("iD.actions.Disconnect", function () { // // Expected result: // a ---- b ---- c ---- d - var graph = iD.Graph({ - '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']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'a']}) + ]); graph = iD.actions.Disconnect('a', 'd')(graph); expect(graph.entity('w').nodes).to.eql(['a', 'b', 'c', 'd']); }); @@ -131,14 +131,14 @@ describe("iD.actions.Disconnect", function () { it("copies location and tags to the new nodes", function () { var tags = {highway: 'traffic_signals'}, loc = [1, 2], - graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b', loc: loc, tags: tags}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}) - }); + graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b', loc: loc, tags: tags}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}) + ]); graph = iD.actions.Disconnect('b', 'e')(graph); diff --git a/test/spec/actions/join.js b/test/spec/actions/join.js index e84203f2f..c2d2090ca 100644 --- a/test/spec/actions/join.js +++ b/test/spec/actions/join.js @@ -2,67 +2,67 @@ describe("iD.actions.Join", function () { describe("#disabled", function () { it("returns falsy for ways that share an end/start node", function () { // a --> b ==> c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}) + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); it("returns falsy for ways that share a start/end node", function () { // a <-- b <== c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['b', 'a']}), - '=': iD.Way({id: '=', nodes: ['c', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['b', 'a']}), + iD.Way({id: '=', nodes: ['c', 'b']}) + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); it("returns falsy for ways that share a start/start node", function () { // a <-- b ==> c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['b', 'a']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['b', 'a']}), + iD.Way({id: '=', nodes: ['b', 'c']}) + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); it("returns falsy for ways that share an end/end node", function () { // a --> b <== c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'b']}) + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); it("returns falsy for more than two ways when connected, regardless of order", function () { // a --> b ==> c ~~> d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}) + ]); expect(iD.actions.Join(['-', '=', '~']).disabled(graph)).not.to.be.ok; expect(iD.actions.Join(['-', '~', '=']).disabled(graph)).not.to.be.ok; @@ -73,9 +73,9 @@ describe("iD.actions.Join", function () { }); it("returns 'not_eligible' for non-line geometries", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}) + ]); expect(iD.actions.Join(['a']).disabled(graph)).to.equal('not_eligible'); }); @@ -84,14 +84,14 @@ describe("iD.actions.Join", function () { // a -- b -- c // | // d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '=': iD.Way({id: '=', nodes: ['b', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '=', nodes: ['b', 'd']}) + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('not_adjacent'); }); @@ -101,18 +101,18 @@ describe("iD.actions.Join", function () { // from: - // to: = // via: b - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ {type: 'way', id: '-', role: 'from'}, {type: 'way', id: '=', role: 'to'}, {type: 'node', id: 'b', role: 'via'} ]}) - }); + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('restriction'); }); @@ -124,20 +124,20 @@ describe("iD.actions.Join", function () { // from: - // to: | // via: b - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '|': iD.Way({id: '|', nodes: ['b', 'd']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '|', nodes: ['b', 'd']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ {type: 'way', id: '-', role: 'from'}, {type: 'way', id: '|', role: 'to'}, {type: 'node', id: 'b', role: 'via'} ]}) - }); + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('restriction'); }); @@ -149,20 +149,20 @@ describe("iD.actions.Join", function () { // from: - // to: | // via: a - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '|': iD.Way({id: '|', nodes: ['a', 'd']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '|', nodes: ['a', 'd']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ {type: 'way', id: '-', role: 'from'}, {type: 'way', id: '|', role: 'to'}, {type: 'node', id: 'a', role: 'via'} ]}) - }); + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); @@ -176,21 +176,21 @@ describe("iD.actions.Join", function () { // from: | // to: \ // via: b - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}), - '\\': iD.Way({id: '\\', nodes: ['b', 'e']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}), + iD.Way({id: '\\', nodes: ['b', 'e']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ {type: 'way', id: '|', role: 'from'}, {type: 'way', id: '\\', role: 'to'}, {type: 'node', id: 'b', role: 'via'} ]}) - }); + ]); expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok; }); @@ -199,13 +199,13 @@ describe("iD.actions.Join", function () { it("joins a --> b ==> c", function () { // Expected result: // a --> b --> c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}) + ]); graph = iD.actions.Join(['-', '='])(graph); @@ -216,13 +216,13 @@ describe("iD.actions.Join", function () { it("joins a <-- b <== c", function () { // Expected result: // a <-- b <-- c - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['b', 'a']}), - '=': iD.Way({id: '=', nodes: ['c', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['b', 'a']}), + iD.Way({id: '=', nodes: ['c', 'b']}) + ]); graph = iD.actions.Join(['-', '='])(graph); @@ -234,13 +234,13 @@ describe("iD.actions.Join", function () { // Expected result: // a <-- b <-- c // tags on === reversed - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['b', 'a']}), - '=': iD.Way({id: '=', nodes: ['b', 'c'], tags: {'lanes:forward': 2}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['b', 'a']}), + iD.Way({id: '=', nodes: ['b', 'c'], tags: {'lanes:forward': 2}}) + ]); graph = iD.actions.Join(['-', '='])(graph); @@ -253,13 +253,13 @@ describe("iD.actions.Join", function () { // Expected result: // a --> b --> c // tags on === reversed - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}) + ]); graph = iD.actions.Join(['-', '='])(graph); @@ -272,17 +272,17 @@ describe("iD.actions.Join", function () { // Expected result: // a --> b --> c --> d --> e // tags on === reversed - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - 'e': iD.Node({id: 'e'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}), - '+': iD.Way({id: '+', nodes: ['d', 'c']}), - '*': iD.Way({id: '*', nodes: ['d', 'e'], tags: {'lanes:backward': 2}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Node({id: 'e'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}), + iD.Way({id: '+', nodes: ['d', 'c']}), + iD.Way({id: '*', nodes: ['d', 'e'], tags: {'lanes:backward': 2}}) + ]); graph = iD.actions.Join(['-', '=', '+', '*'])(graph); @@ -298,15 +298,15 @@ describe("iD.actions.Join", function () { // --- is new, === is existing, +++ is new // Expected result: // a ==> b ==> c ==> d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - 'w-1': iD.Way({id: 'w-1', nodes: ['a', 'b']}), - 'w1': iD.Way({id: 'w1', nodes: ['b', 'c']}), - 'w-2': iD.Way({id: 'w-2', nodes: ['c', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: 'w-1', nodes: ['a', 'b']}), + iD.Way({id: 'w1', nodes: ['b', 'c']}), + iD.Way({id: 'w-2', nodes: ['c', 'd']}) + ]); graph = iD.actions.Join(['w-1', 'w1', 'w-2'])(graph); @@ -316,15 +316,15 @@ describe("iD.actions.Join", function () { }); it("merges tags", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b'], tags: {a: 'a', b: '-', c: 'c'}}), - '=': iD.Way({id: '=', nodes: ['b', 'c'], tags: {a: 'a', b: '=', d: 'd'}}), - '+': iD.Way({id: '+', nodes: ['c', 'd'], tags: {a: 'a', b: '=', e: 'e'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b'], tags: {a: 'a', b: '-', c: 'c'}}), + iD.Way({id: '=', nodes: ['b', 'c'], tags: {a: 'a', b: '=', d: 'd'}}), + iD.Way({id: '+', nodes: ['c', 'd'], tags: {a: 'a', b: '=', e: 'e'}}) + ]); graph = iD.actions.Join(['-', '=', '+'])(graph); @@ -332,15 +332,15 @@ describe("iD.actions.Join", function () { }); it("merges relations", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['b', 'c']}), - 'r1': iD.Relation({id: 'r1', members: [{id: '=', role: 'r1', type: 'way'}]}), - 'r2': iD.Relation({id: 'r2', members: [{id: '=', role: 'r2', type: 'way'}, {id: '-', role: 'r2', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['b', 'c']}), + iD.Relation({id: 'r1', members: [{id: '=', role: 'r1', type: 'way'}]}), + iD.Relation({id: 'r2', members: [{id: '=', role: 'r2', type: 'way'}, {id: '-', role: 'r2', type: 'way'}]}) + ]); graph = iD.actions.Join(['-', '='])(graph); diff --git a/test/spec/actions/merge.js b/test/spec/actions/merge.js index 9134c3866..a01a3e443 100644 --- a/test/spec/actions/merge.js +++ b/test/spec/actions/merge.js @@ -1,11 +1,11 @@ describe("iD.actions.Merge", function () { it("merges multiple points to a line", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', tags: {a: 'a'}}), - 'b': iD.Node({id: 'b', tags: {b: 'b'}}), - 'w': iD.Way({id: 'w'}), - 'r': iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', tags: {a: 'a'}}), + iD.Node({id: 'b', tags: {b: 'b'}}), + iD.Way({id: 'w'}), + iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]}) + ]), action = iD.actions.Merge(['a', 'b', 'w']); expect(action.disabled(graph)).not.to.be.ok; @@ -19,12 +19,12 @@ describe("iD.actions.Merge", function () { }); it("merges multiple points to an area", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', tags: {a: 'a'}}), - 'b': iD.Node({id: 'b', tags: {b: 'b'}}), - 'w': iD.Way({id: 'w', tags: {area: 'yes'}}), - 'r': iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', tags: {a: 'a'}}), + iD.Node({id: 'b', tags: {b: 'b'}}), + iD.Way({id: 'w', tags: {area: 'yes'}}), + iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]}) + ]), action = iD.actions.Merge(['a', 'b', 'w']); expect(action.disabled(graph)).not.to.be.ok; diff --git a/test/spec/actions/orthogonalize.js b/test/spec/actions/orthogonalize.js index 3f185508e..310aef05d 100644 --- a/test/spec/actions/orthogonalize.js +++ b/test/spec/actions/orthogonalize.js @@ -2,13 +2,13 @@ describe("iD.actions.Orthogonalize", function () { var projection = d3.geo.mercator(); it("orthogonalizes a perfect quad", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); graph = iD.actions.Orthogonalize('-', projection)(graph); @@ -16,13 +16,13 @@ describe("iD.actions.Orthogonalize", function () { }); it("orthogonalizes a quad", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [4, 0]}), - 'c': iD.Node({id: 'c', loc: [3, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [4, 0]}), + iD.Node({id: 'c', loc: [3, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); graph = iD.actions.Orthogonalize('-', projection)(graph); @@ -30,12 +30,12 @@ describe("iD.actions.Orthogonalize", function () { }); it("orthogonalizes a triangle", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [3, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [3, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a']}) + ]); graph = iD.actions.Orthogonalize('-', projection)(graph); @@ -43,14 +43,14 @@ describe("iD.actions.Orthogonalize", function () { }); it("deletes empty redundant nodes", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [1, 2]}), - 'e': iD.Node({id: 'e', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [1, 2]}), + iD.Node({id: 'e', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) + ]); graph = iD.actions.Orthogonalize('-', projection)(graph); @@ -58,14 +58,14 @@ describe("iD.actions.Orthogonalize", function () { }); it("preserves non empty redundant nodes", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [1, 2], tags: {foo: 'bar'}}), - 'e': iD.Node({id: 'e', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [1, 2], tags: {foo: 'bar'}}), + iD.Node({id: 'e', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']}) + ]); graph = iD.actions.Orthogonalize('-', projection)(graph); @@ -90,13 +90,13 @@ describe("iD.actions.Orthogonalize", function () { ]; for (var i = 0; i < tests.length; i++) { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: tests[i][0]}), - 'b': iD.Node({id: 'b', loc: tests[i][1]}), - 'c': iD.Node({id: 'c', loc: tests[i][2]}), - 'd': iD.Node({id: 'd', loc: tests[i][3]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', loc: tests[i][0]}), + iD.Node({id: 'b', loc: tests[i][1]}), + iD.Node({id: 'c', loc: tests[i][2]}), + iD.Node({id: 'd', loc: tests[i][3]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]), initialWidth = iD.geo.sphericalDistance(graph.entity('a').loc, graph.entity('b').loc), finalWidth; @@ -108,15 +108,15 @@ describe("iD.actions.Orthogonalize", function () { }); it("only moves nodes which are near right or near straight", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [3, 0.001]}), - 'c': iD.Node({id: 'c', loc: [3, 1]}), - 'd': iD.Node({id: 'd', loc: [2, 1]}), - 'e': iD.Node({id: 'e', loc: [1, 2]}), - 'f': iD.Node({id: 'f', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'f', 'a']}) - }), + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [3, 0.001]}), + iD.Node({id: 'c', loc: [3, 1]}), + iD.Node({id: 'd', loc: [2, 1]}), + iD.Node({id: 'e', loc: [1, 2]}), + iD.Node({id: 'f', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'f', 'a']}) + ]), diff = iD.Difference(graph, iD.actions.Orthogonalize('-', projection)(graph)); expect(Object.keys(diff.changes()).sort()).to.eql(['a', 'b', 'c', 'f']); diff --git a/test/spec/actions/split.js b/test/spec/actions/split.js index 90b054274..8d1535379 100644 --- a/test/spec/actions/split.js +++ b/test/spec/actions/split.js @@ -1,86 +1,86 @@ describe("iD.actions.Split", function () { describe("#disabled", function () { it("returns falsy for a non-end node of a single way", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}) + ]); expect(iD.actions.Split('b').disabled(graph)).not.to.be.ok; }); it("returns falsy for an intersection of two ways", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['c', '*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['c', '*', 'd']}) + ]); expect(iD.actions.Split('*').disabled(graph)).not.to.be.ok; }); it("returns falsy for an intersection of two ways with parent way specified", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['c', '*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['c', '*', 'd']}) + ]); expect(iD.actions.Split('*').limitWays(['-']).disabled(graph)).not.to.be.ok; }); it("returns falsy for a self-intersection", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']}) + ]); expect(iD.actions.Split('a').disabled(graph)).not.to.be.ok; }); it("returns 'not_eligible' for the first node of a single way", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Way({id: '-', nodes: ['a', 'b']}) + ]); expect(iD.actions.Split('a').disabled(graph)).to.equal('not_eligible'); }); it("returns 'not_eligible' for the last node of a single way", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Way({id: '-', nodes: ['a', 'b']}) + ]); expect(iD.actions.Split('b').disabled(graph)).to.equal('not_eligible'); }); it("returns 'not_eligible' for an intersection of two ways with non-parent way specified", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['c', '*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['c', '*', 'd']}) + ]); expect(iD.actions.Split('*').limitWays(['-', '=']).disabled(graph)).to.equal('not_eligible'); }); @@ -95,12 +95,12 @@ describe("iD.actions.Split", function () { // Expected result: // a ---- b ==== c // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -110,12 +110,12 @@ describe("iD.actions.Split", function () { it("copies tags to the new way", function () { var tags = {highway: 'residential'}, - graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c'], tags: tags}) - }); + graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c'], tags: tags}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -137,14 +137,14 @@ describe("iD.actions.Split", function () { // | // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '|': iD.Way({id: '|', nodes: ['d', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '|', nodes: ['d', 'b']}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -170,15 +170,15 @@ describe("iD.actions.Split", function () { // ¦ // d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['c', '*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['c', '*', 'd']}) + ]); graph = iD.actions.Split('*', ['=', '¦'])(graph); @@ -189,15 +189,15 @@ describe("iD.actions.Split", function () { }); it("splits the specified ways at an intersection", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '*': iD.Node({id: '*'}), - '-': iD.Way({id: '-', nodes: ['a', '*', 'b']}), - '|': iD.Way({id: '|', nodes: ['c', '*', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Node({id: '*'}), + iD.Way({id: '-', nodes: ['a', '*', 'b']}), + iD.Way({id: '|', nodes: ['c', '*', 'd']}) + ]); var g1 = iD.actions.Split('*', ['=']).limitWays(['-'])(graph); expect(g1.entity('-').nodes).to.eql(['a', '*']); @@ -231,13 +231,13 @@ describe("iD.actions.Split", function () { // / | // c - a == d // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']}) + ]); graph = iD.actions.Split('a', ['='])(graph); @@ -258,13 +258,13 @@ describe("iD.actions.Split", function () { // || | // d ==== c // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0,1]}), - 'b': iD.Node({id: 'b', loc: [1,1]}), - 'c': iD.Node({id: 'c', loc: [1,0]}), - 'd': iD.Node({id: 'd', loc: [0,0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0,1]}), + iD.Node({id: 'b', loc: [1,1]}), + iD.Node({id: 'c', loc: [1,0]}), + iD.Node({id: 'd', loc: [0,0]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); var g1 = iD.actions.Split('a', ['='])(graph); expect(g1.entity('-').nodes).to.eql(['a', 'b', 'c']); @@ -284,13 +284,13 @@ describe("iD.actions.Split", function () { }); it("splits an area by converting it to a multipolygon", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0,1]}), - 'b': iD.Node({id: 'b', loc: [1,1]}), - 'c': iD.Node({id: 'c', loc: [1,0]}), - 'd': iD.Node({id: 'd', loc: [0,0]}), - '-': iD.Way({id: '-', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0,1]}), + iD.Node({id: 'b', loc: [1,1]}), + iD.Node({id: 'c', loc: [1,0]}), + iD.Node({id: 'd', loc: [0,0]}), + iD.Way({id: '-', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}) + ]); graph = iD.actions.Split('a', ['='])(graph); expect(graph.entity('-').tags).to.eql({}); @@ -306,13 +306,13 @@ describe("iD.actions.Split", function () { }); it("splits only the line of a node shared by a line and an area", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0,1]}), - 'b': iD.Node({id: 'b', loc: [1,1]}), - 'c': iD.Node({id: 'c', loc: [1,0]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '=': iD.Way({id: '=', nodes: ['a', 'b', 'c', 'a'], tags: {area: 'yes'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0,1]}), + iD.Node({id: 'b', loc: [1,1]}), + iD.Node({id: 'c', loc: [1,0]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '=', nodes: ['a', 'b', 'c', 'a'], tags: {area: 'yes'}}) + ]); graph = iD.actions.Split('b', ['~'])(graph); @@ -333,13 +333,13 @@ describe("iD.actions.Split", function () { // a ---- b ==== c // Relation: [----, ====] // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'forward'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'forward'}]}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -360,15 +360,15 @@ describe("iD.actions.Split", function () { // a ---- b ==== c ~~~~ d // Relation: [----, ====, ~~~~] // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -386,15 +386,15 @@ describe("iD.actions.Split", function () { // a ---- b ==== c ~~~~ d // Relation: [~~~~, ====, ----] // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -402,13 +402,13 @@ describe("iD.actions.Split", function () { }); it("handles incomplete relations", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - 'r': iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -416,13 +416,13 @@ describe("iD.actions.Split", function () { }); it("converts simple multipolygon to a proper multipolygon", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({'id': '-', nodes: ['a', 'b', 'c'], tags: {natural: 'water'}}), - 'r': iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'outer'}], tags: {type: 'multipolygon'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({'id': '-', nodes: ['a', 'b', 'c'], tags: {natural: 'water'}}), + iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'outer'}], tags: {type: 'multipolygon'}}) + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -443,18 +443,18 @@ describe("iD.actions.Split", function () { // a ----> b ====> c ~~~~ d // A restriction from ==== to ~~~~ via c. // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', tags: {type: type}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', tags: {type: type}, members: [ {id: '-', role: 'from'}, {id: '~', role: 'to'}, {id: 'c', role: 'via'}]}) - }); + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -475,18 +475,18 @@ describe("iD.actions.Split", function () { // a ----> b ====> c ~~~~ d // A restriction from ~~~~ to ==== via c. // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', tags: {type: type}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', tags: {type: type}, members: [ {id: '~', role: 'from'}, {id: '-', role: 'to'}, {id: 'c', role: 'via'}]}) - }); + ]); graph = iD.actions.Split('b', ['='])(graph); @@ -507,18 +507,18 @@ describe("iD.actions.Split", function () { // a <==== b <---- c ~~~~ d // A restriction from ---- to ~~~~ via c. // - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - 'd': iD.Node({id: 'd'}), - '-': iD.Way({id: '-', nodes: ['c', 'b', 'a']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', tags: {type: type}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Node({id: 'd'}), + iD.Way({id: '-', nodes: ['c', 'b', 'a']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', tags: {type: type}, members: [ {id: '-', role: 'from'}, {id: '~', role: 'to'}, {id: 'c', role: 'via'}]}) - }); + ]); graph = iD.actions.Split('b', ['='])(graph); diff --git a/test/spec/actions/straighten.js b/test/spec/actions/straighten.js index e58b69718..8f43683c6 100644 --- a/test/spec/actions/straighten.js +++ b/test/spec/actions/straighten.js @@ -2,12 +2,12 @@ describe("iD.actions.Straighten", function () { var projection = d3.geo.mercator(); it("deletes empty nodes", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0], tags: {}}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0], tags: {}}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}) + ]); graph = iD.actions.Straighten('-', projection)(graph); @@ -15,12 +15,12 @@ describe("iD.actions.Straighten", function () { }); it("does not delete tagged nodes", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0], tags: {foo: 'bar'}}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0], tags: {foo: 'bar'}}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c']}) + ]); graph = iD.actions.Straighten('-', projection)(graph); @@ -28,14 +28,14 @@ describe("iD.actions.Straighten", function () { }); it("does not delete nodes connected to other ways", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [2, 0]}), - 'c': iD.Node({id: 'c', loc: [2, 2]}), - 'd': iD.Node({id: 'd', loc: [0, 2]}), - '-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd']}), - '=': iD.Way({id: '=', nodes: ['b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [2, 0]}), + iD.Node({id: 'c', loc: [2, 2]}), + iD.Node({id: 'd', loc: [0, 2]}), + iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd']}), + iD.Way({id: '=', nodes: ['b']}) + ]); graph = iD.actions.Straighten('-', projection)(graph); diff --git a/test/spec/core/difference.js b/test/spec/core/difference.js index 671950cd5..ac51bd810 100644 --- a/test/spec/core/difference.js +++ b/test/spec/core/difference.js @@ -127,12 +127,12 @@ describe("iD.Difference", function () { }); describe("#summary", function () { - var base = iD.Graph({ - 'a': iD.Node({id: 'a', tags: {crossing: 'zebra'}}), - 'b': iD.Node({id: 'b'}), - 'v': iD.Node({id: 'v'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}) - }); + var base = iD.Graph([ + iD.Node({id: 'a', tags: {crossing: 'zebra'}}), + iD.Node({id: 'b'}), + iD.Node({id: 'v'}), + iD.Way({id: '-', nodes: ['a', 'b']}) + ]); it("reports a created way as created", function() { var way = iD.Way({id: '+'}), diff --git a/test/spec/core/entity.js b/test/spec/core/entity.js index bbaaec08f..79d1fb753 100644 --- a/test/spec/core/entity.js +++ b/test/spec/core/entity.js @@ -204,18 +204,18 @@ describe('iD.Entity', function () { describe("#area", function() { it("returns a relative measure of area", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), - 'b': iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), - 'c': iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), - 'd': iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), - 'e': iD.Node({id: 'a', loc: [-0.0004, 0.0002]}), - 'f': iD.Node({id: 'b', loc: [ 0.0004, 0.0002]}), - 'g': iD.Node({id: 'c', loc: [ 0.0004, -0.0002]}), - 'h': iD.Node({id: 'd', loc: [-0.0004, -0.0002]}), - 's': iD.Way({id: 's', tags: {area: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}), - 'l': iD.Way({id: 'l', tags: {area: 'yes'}, nodes: ['e', 'f', 'g', 'h', 'e']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), + iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), + iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), + iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), + iD.Node({id: 'e', loc: [-0.0004, 0.0002]}), + iD.Node({id: 'f', loc: [ 0.0004, 0.0002]}), + iD.Node({id: 'g', loc: [ 0.0004, -0.0002]}), + iD.Node({id: 'h', loc: [-0.0004, -0.0002]}), + iD.Way({id: 's', tags: {area: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}), + iD.Way({id: 'l', tags: {area: 'yes'}, nodes: ['e', 'f', 'g', 'h', 'e']}) + ]); var s = Math.abs(graph.entity('s').area(graph)), l = Math.abs(graph.entity('l').area(graph)); @@ -224,15 +224,15 @@ describe('iD.Entity', function () { }); it("returns 0 for degenerate areas", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), - 'b': iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), - 'c': iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), - 'd': iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), - '0': iD.Way({id: '0', tags: {area: 'yes'}, nodes: []}), - '1': iD.Way({id: '1', tags: {area: 'yes'}, nodes: ['a']}), - '2': iD.Way({id: '2', tags: {area: 'yes'}, nodes: ['a', 'b']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), + iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), + iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), + iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), + iD.Way({id: '0', tags: {area: 'yes'}, nodes: []}), + iD.Way({id: '1', tags: {area: 'yes'}, nodes: ['a']}), + iD.Way({id: '2', tags: {area: 'yes'}, nodes: ['a', 'b']}) + ]); expect(graph.entity('0').area(graph)).to.equal(0); expect(graph.entity('1').area(graph)).to.equal(0); diff --git a/test/spec/core/graph.js b/test/spec/core/graph.js index 86f1cbab9..5df07a336 100644 --- a/test/spec/core/graph.js +++ b/test/spec/core/graph.js @@ -344,7 +344,7 @@ describe('iD.Graph', function() { }); it("returns self if self is not frozen", function () { - var graph = iD.Graph({}, true); + var graph = iD.Graph([], true); expect(graph.update()).to.equal(graph); }); @@ -385,7 +385,7 @@ describe('iD.Graph', 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({n1: node, w1: way}); + graph = iD.Graph([node, way]); expect(graph.parentWays(node)).to.eql([way]); expect(graph.parentWays(way)).to.eql([]); }); @@ -394,9 +394,9 @@ describe('iD.Graph', function() { 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"}), + nonnode = iD.Node({id: "n2"}), relation = iD.Relation({id: "r1", members: [{ id: "n1", role: 'from' }]}), - graph = iD.Graph({n1: node, r1: relation}); + graph = iD.Graph([node, relation]); expect(graph.parentRelations(node)).to.eql([relation]); expect(graph.parentRelations(nonnode)).to.eql([]); }); @@ -406,7 +406,7 @@ describe('iD.Graph', 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({n1: node, w1: way}); + graph = iD.Graph([node, way]); expect(graph.childNodes(way)).to.eql([node]); }); }); diff --git a/test/spec/geo/multipolygon.js b/test/spec/geo/multipolygon.js index a68a2c553..c4a512fc5 100644 --- a/test/spec/geo/multipolygon.js +++ b/test/spec/geo/multipolygon.js @@ -57,20 +57,20 @@ describe("iD.geo.joinWays", function() { it("returns the members in the correct order", function() { // a<===b--->c~~~>d - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [0, 0]}), - 'c': iD.Node({id: 'c', loc: [0, 0]}), - 'd': iD.Node({id: 'd', loc: [0, 0]}), - '=': iD.Way({id: '=', nodes: ['b', 'a']}), - '-': iD.Way({id: '-', nodes: ['b', 'c']}), - '~': iD.Way({id: '~', nodes: ['c', 'd']}), - 'r': iD.Relation({id: 'r', members: [ + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [0, 0]}), + iD.Node({id: 'c', loc: [0, 0]}), + iD.Node({id: 'd', loc: [0, 0]}), + iD.Way({id: '=', nodes: ['b', 'a']}), + iD.Way({id: '-', nodes: ['b', 'c']}), + iD.Way({id: '~', nodes: ['c', 'd']}), + iD.Relation({id: 'r', members: [ {id: '-', type: 'way'}, {id: '~', type: 'way'}, {id: '=', type: 'way'} ]}) - }); + ]); var result = iD.geo.joinWays(graph.entity('r').members, graph); expect(_.pluck(result[0], 'id')).to.eql(['=', '-', '~']); @@ -81,13 +81,13 @@ describe("iD.geo.joinWays", function() { // Expected result: // a --> b --> c // tags on === reversed - var graph = iD.Graph({ - 'a': iD.Node({id: 'a'}), - 'b': iD.Node({id: 'b'}), - 'c': iD.Node({id: 'c'}), - '-': iD.Way({id: '-', nodes: ['a', 'b']}), - '=': iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a'}), + iD.Node({id: 'b'}), + iD.Node({id: 'c'}), + iD.Way({id: '-', nodes: ['a', 'b']}), + iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}}) + ]); var result = iD.geo.joinWays([graph.entity('-'), graph.entity('=')], graph); expect(result[0][1].tags).to.eql({'lanes:backward': 2}); diff --git a/test/spec/geo/turn.js b/test/spec/geo/turn.js index e4d378667..4d0c87cac 100644 --- a/test/spec/geo/turn.js +++ b/test/spec/geo/turn.js @@ -1,84 +1,84 @@ describe("iD.geo.turns", function() { it("returns an empty array for non-ways", function() { - var graph = iD.Graph({ - 'n': iD.Node({id: 'n'}) - }); + var graph = iD.Graph([ + iD.Node({id: 'n'}) + ]); expect(iD.geo.turns(graph, 'n')).to.eql([]); }); it("returns an empty array for non-lines", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', area: 'yes'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', area: 'yes'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("returns an empty array for an unconnected way", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - '=': iD.Way({id: '=', nodes: ['u', 'v']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Way({id: '=', nodes: ['u', 'v']}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns onto degenerate ways", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns from non-highways", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v']}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v']}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns onto non-highways", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w']}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns onto non-lines", function() { - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - 'x': iD.Node({id: 'x'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w', 'x', 'v'], tags: {highway: 'residential', area: 'yes'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Node({id: 'x'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w', 'x', 'v'], tags: {highway: 'residential', area: 'yes'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("permits turns onto a way forward", function() { // u====v--->w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -89,13 +89,13 @@ describe("iD.geo.turns", function() { it("permits turns onto a way backward", function() { // u====v<---w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -110,14 +110,14 @@ describe("iD.geo.turns", function() { // u===v // | // x - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - 'x': iD.Node({id: 'x'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['w', 'v', 'x'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Node({id: 'x'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['w', 'v', 'x'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -133,13 +133,13 @@ describe("iD.geo.turns", function() { it("permits turns from a oneway forward", function() { // u===>v----w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', oneway: 'yes'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', oneway: 'yes'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -150,13 +150,13 @@ describe("iD.geo.turns", function() { it("permits turns from a reverse oneway backward", function() { // u<===v----w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['v', 'u'], tags: {highway: 'residential', oneway: '-1'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['v', 'u'], tags: {highway: 'residential', oneway: '-1'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -167,37 +167,37 @@ describe("iD.geo.turns", function() { it("omits turns from a oneway backward", function() { // u<===v----w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['v', 'u'], tags: {highway: 'residential', oneway: 'yes'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['v', 'u'], tags: {highway: 'residential', oneway: 'yes'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns from a reverse oneway forward", function() { // u===>v----w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', oneway: '-1'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential', oneway: '-1'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("permits turns onto a oneway forward", function() { // u====v--->w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential', oneway: 'yes'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential', oneway: 'yes'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -208,13 +208,13 @@ describe("iD.geo.turns", function() { it("permits turns onto a reverse oneway backward", function() { // u====v<---w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential', oneway: '-1'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential', oneway: '-1'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), @@ -225,42 +225,42 @@ describe("iD.geo.turns", function() { it("omits turns onto a oneway backward", function() { // u====v<---w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential', oneway: 'yes'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['w', 'v'], tags: {highway: 'residential', oneway: 'yes'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("omits turns onto a reverse oneway forward", function() { // u====v--->w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential', oneway: '-1'}}) - }); + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential', oneway: '-1'}}) + ]); expect(iD.geo.turns(graph, '=')).to.eql([]); }); it("restricts turns with a restriction relation", function() { // u====v--->w - var graph = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - '=': iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), - '-': iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: '=', nodes: ['u', 'v'], tags: {highway: 'residential'}}), + iD.Way({id: '-', nodes: ['v', 'w'], tags: {highway: 'residential'}}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ {id: '=', role: 'from', type: 'way'}, {id: '-', role: 'to', type: 'way'}, {id: 'v', role: 'via', type: 'node'} ]}) - }); + ]); expect(iD.geo.turns(graph, '=')).to.eql([{ from: graph.entity('='), to: graph.entity('-'), diff --git a/test/spec/svg/areas.js b/test/spec/svg/areas.js index 6bd61a894..178f42810 100644 --- a/test/spec/svg/areas.js +++ b/test/spec/svg/areas.js @@ -11,13 +11,13 @@ describe("iD.svg.Areas", function () { }); it("adds way and area classes", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [1, 0]}), - 'c': iD.Node({id: 'c', loc: [1, 1]}), - 'd': iD.Node({id: 'd', loc: [0, 1]}), - 'w': iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [1, 0]}), + iD.Node({id: 'c', loc: [1, 1]}), + iD.Node({id: 'd', loc: [0, 1]}), + iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']}) + ]); surface.call(iD.svg.Areas(projection), graph, [graph.entity('w')], none); @@ -26,13 +26,13 @@ describe("iD.svg.Areas", function () { }); it("adds tag classes", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [1, 0]}), - 'c': iD.Node({id: 'c', loc: [1, 1]}), - 'd': iD.Node({id: 'd', loc: [0, 1]}), - 'w': iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [1, 0]}), + iD.Node({id: 'c', loc: [1, 1]}), + iD.Node({id: 'd', loc: [0, 1]}), + iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']}) + ]); surface.call(iD.svg.Areas(projection), graph, [graph.entity('w')], none); @@ -54,14 +54,14 @@ describe("iD.svg.Areas", function () { }); it("handles deletion of a way and a member vertex (#1903)", function () { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [0, 0]}), - 'b': iD.Node({id: 'b', loc: [1, 0]}), - 'c': iD.Node({id: 'c', loc: [1, 1]}), - 'd': iD.Node({id: 'd', loc: [1, 1]}), - 'w': iD.Way({id: 'w', tags: {area: 'yes'}, nodes: ['a', 'b', 'c', 'a']}), - 'x': iD.Way({id: 'x', tags: {area: 'yes'}, nodes: ['a', 'b', 'd', 'a']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [0, 0]}), + iD.Node({id: 'b', loc: [1, 0]}), + iD.Node({id: 'c', loc: [1, 1]}), + iD.Node({id: 'd', loc: [1, 1]}), + iD.Way({id: 'w', tags: {area: 'yes'}, nodes: ['a', 'b', 'c', 'a']}), + iD.Way({id: 'x', tags: {area: 'yes'}, nodes: ['a', 'b', 'd', 'a']}) + ]); surface.call(iD.svg.Areas(projection), graph, [graph.entity('x')], all); graph = graph.remove(graph.entity('x')).remove(graph.entity('d')); @@ -71,18 +71,18 @@ describe("iD.svg.Areas", function () { }); describe("z-indexing", function() { - var graph = iD.Graph({ - 'a': iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), - 'b': iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), - 'c': iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), - 'd': iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), - 'e': iD.Node({id: 'a', loc: [-0.0004, 0.0002]}), - 'f': iD.Node({id: 'b', loc: [ 0.0004, 0.0002]}), - 'g': iD.Node({id: 'c', loc: [ 0.0004, -0.0002]}), - 'h': iD.Node({id: 'd', loc: [-0.0004, -0.0002]}), - 's': iD.Way({id: 's', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}), - 'l': iD.Way({id: 'l', tags: {landuse: 'park'}, nodes: ['e', 'f', 'g', 'h', 'e']}) - }); + var graph = iD.Graph([ + iD.Node({id: 'a', loc: [-0.0002, 0.0001]}), + iD.Node({id: 'b', loc: [ 0.0002, 0.0001]}), + iD.Node({id: 'c', loc: [ 0.0002, -0.0001]}), + iD.Node({id: 'd', loc: [-0.0002, -0.0001]}), + iD.Node({id: 'e', loc: [-0.0004, 0.0002]}), + iD.Node({id: 'f', loc: [ 0.0004, 0.0002]}), + iD.Node({id: 'g', loc: [ 0.0004, -0.0002]}), + iD.Node({id: 'h', loc: [-0.0004, -0.0002]}), + iD.Way({id: 's', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']}), + iD.Way({id: 'l', tags: {landuse: 'park'}, nodes: ['e', 'f', 'g', 'h', 'e']}) + ]); it("stacks smaller areas above larger ones in a single render", function () { surface.call(iD.svg.Areas(projection), graph, [graph.entity('s'), graph.entity('l')], none); diff --git a/test/spec/svg/restrictions.js b/test/spec/svg/restrictions.js index dc6169eb5..38f3bf1b9 100644 --- a/test/spec/svg/restrictions.js +++ b/test/spec/svg/restrictions.js @@ -12,18 +12,18 @@ describe("iD.svg.Restrictions", function() { expect(restrictions.turns(graph, ['a', 'b'])).to.eql([]); }); - var valid = iD.Graph({ - 'u': iD.Node({id: 'u'}), - 'v': iD.Node({id: 'v'}), - 'w': iD.Node({id: 'w'}), - 'f': iD.Way({id: 'f', nodes: ['u', 'v']}), - 't': iD.Way({id: 't', nodes: ['v', 'w']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var valid = iD.Graph([ + iD.Node({id: 'u'}), + iD.Node({id: 'v'}), + iD.Node({id: 'w'}), + iD.Way({id: 'f', nodes: ['u', 'v']}), + iD.Way({id: 't', nodes: ['v', 'w']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ { role: 'via', id: 'v', type: 'node' }, { role: 'from', id: 'f', type: 'way' }, { role: 'to', id: 't', type: 'way' } ]}) - }); + ]); it("returns a valid restriction when the selected way has role 'from'", function() { expect(restrictions.turns(valid, ['f'])).to.eql([valid.entity('r')]); @@ -106,20 +106,20 @@ describe("iD.svg.Restrictions", function() { // u====>v // From = to - via v - var graph = iD.Graph({ - 'u': iD.Node({id: 'u', loc: [0, 0]}), - 'v': iD.Node({id: 'v', loc: [1, 0]}), - 'w': iD.Node({id: 'w', loc: [1, 1]}), - 'x': iD.Node({id: 'w', loc: [2, 1]}), - 'y': iD.Node({id: 'w', loc: [3, 1]}), - '=': iD.Way({id: '=', nodes: ['u', 'v']}), - '-': iD.Way({id: '-', nodes: ['v', 'w', 'x', 'y']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'u', loc: [0, 0]}), + iD.Node({id: 'v', loc: [1, 0]}), + iD.Node({id: 'w', loc: [1, 1]}), + iD.Node({id: 'x', loc: [2, 1]}), + iD.Node({id: 'y', loc: [3, 1]}), + iD.Way({id: '=', nodes: ['u', 'v']}), + iD.Way({id: '-', nodes: ['v', 'w', 'x', 'y']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ { role: 'via', id: 'v', type: 'node' }, { role: 'from', id: '=', type: 'way' }, { role: 'to', id: '-', type: 'way' } ]}) - }); + ]); expect(restrictions.datum(graph, graph.entity('='), graph.entity('r'), projection).angle).to.eql(Math.PI / 2); }); @@ -130,20 +130,20 @@ describe("iD.svg.Restrictions", function() { // u====>v // From = to - via v - var graph = iD.Graph({ - 'u': iD.Node({id: 'u', loc: [0, 0]}), - 'v': iD.Node({id: 'v', loc: [1, 0]}), - 'w': iD.Node({id: 'w', loc: [1, 1]}), - 'x': iD.Node({id: 'w', loc: [2, 1]}), - 'y': iD.Node({id: 'w', loc: [3, 1]}), - '=': iD.Way({id: '=', nodes: ['u', 'v']}), - '-': iD.Way({id: '-', nodes: ['y', 'x', 'w', 'v']}), - 'r': iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ + var graph = iD.Graph([ + iD.Node({id: 'u', loc: [0, 0]}), + iD.Node({id: 'v', loc: [1, 0]}), + iD.Node({id: 'w', loc: [1, 1]}), + iD.Node({id: 'x', loc: [2, 1]}), + iD.Node({id: 'y', loc: [3, 1]}), + iD.Way({id: '=', nodes: ['u', 'v']}), + iD.Way({id: '-', nodes: ['y', 'x', 'w', 'v']}), + iD.Relation({id: 'r', tags: {type: 'restriction'}, members: [ { role: 'via', id: 'v', type: 'node' }, { role: 'from', id: '=', type: 'way' }, { role: 'to', id: '-', type: 'way' } ]}) - }); + ]); expect(restrictions.datum(graph, graph.entity('='), graph.entity('r'), projection).angle).to.eql(Math.PI / 2); });