Merge branch 'master' into conflict-resolution-ui

This commit is contained in:
samanpwbb
2015-02-06 19:08:50 -05:00
79 changed files with 1856 additions and 260 deletions
+4
View File
@@ -127,6 +127,7 @@
<script src='../js/id/actions/change_tags.js'></script>
<script src='../js/id/actions/circularize.js'></script>
<script src='../js/id/actions/connect.js'></script>
<script src='../js/id/actions/copy_entity.js'></script>
<script src='../js/id/actions/delete_member.js'></script>
<script src='../js/id/actions/delete_multiple.js'></script>
<script src='../js/id/actions/delete_node.js'></script>
@@ -151,6 +152,7 @@
<script src='../js/id/behavior.js'></script>
<script src='../js/id/behavior/add_way.js'></script>
<script src='../js/id/behavior/copy.js'></script>
<script src='../js/id/behavior/drag.js'></script>
<script src='../js/id/behavior/draw.js'></script>
<script src='../js/id/behavior/draw_way.js'></script>
@@ -158,6 +160,7 @@
<script src='../js/id/behavior/hash.js'></script>
<script src='../js/id/behavior/hover.js'></script>
<script src='../js/id/behavior/lasso.js'></script>
<script src='../js/id/behavior/paste.js'></script>
<script src='../js/id/behavior/select.js'></script>
<script src='../js/id/behavior/tail.js'></script>
@@ -228,6 +231,7 @@
<script src='spec/actions/orthogonalize.js'></script>
<script src='spec/actions/straighten.js'></script>
<script src='spec/actions/connect.js'></script>
<script src="spec/actions/copy_entity.js"></script>
<script src='spec/actions/delete_member.js'></script>
<script src="spec/actions/delete_multiple.js"></script>
<script src="spec/actions/delete_node.js"></script>
+1
View File
@@ -36,6 +36,7 @@
<script src="spec/actions/change_tags.js"></script>
<script src='spec/actions/circularize.js'></script>
<script src='spec/actions/connect.js'></script>
<script src="spec/actions/copy_entity.js"></script>
<script src='spec/actions/delete_member.js'></script>
<script src="spec/actions/delete_multiple.js"></script>
<script src="spec/actions/delete_node.js"></script>
+76
View File
@@ -0,0 +1,76 @@
describe("iD.actions.CopyEntity", function () {
it("copies a Node and adds it to the graph", function () {
var a = iD.Node({id: 'a'}),
base = iD.Graph([a]),
head = iD.actions.CopyEntity(a)(base),
diff = iD.Difference(base, head),
created = diff.created();
expect(head.hasEntity('a')).to.be.ok;
expect(created).to.have.length(1);
expect(created[0]).to.be.an.instanceof(iD.Node);
});
it("shallow copies a Way and adds it to the graph", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
w = iD.Way({id: 'w', nodes: ['a', 'b']}),
base = iD.Graph([a, b, w]),
head = iD.actions.CopyEntity(w)(base),
diff = iD.Difference(base, head),
created = diff.created();
expect(head.hasEntity('w')).to.be.ok;
expect(created).to.have.length(1);
expect(created[0]).to.be.an.instanceof(iD.Way);
});
it("deep copies a Way and child Nodes and adds them to the graph", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
w = iD.Way({id: 'w', nodes: ['a', 'b']}),
base = iD.Graph([a, b, w]),
head = iD.actions.CopyEntity(w, true)(base),
diff = iD.Difference(base, head),
created = diff.created();
expect(head.hasEntity('w')).to.be.ok;
expect(created).to.have.length(3);
expect(created[0]).to.be.an.instanceof(iD.Way);
expect(created[1]).to.be.an.instanceof(iD.Node);
expect(created[2]).to.be.an.instanceof(iD.Node);
});
it("shallow copies a Relation and adds it to the graph", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
w = iD.Way({id: 'w', nodes: ['a', 'b']}),
r = iD.Relation({id: 'r', members: [{id: 'w'}]}),
base = iD.Graph([a, b, w, r]),
head = iD.actions.CopyEntity(r)(base),
diff = iD.Difference(base, head),
created = diff.created();
expect(head.hasEntity('r')).to.be.ok;
expect(created).to.have.length(1);
expect(created[0]).to.be.an.instanceof(iD.Relation);
});
it("deep copies a Relation, member Ways, and child Nodes and adds them to the graph", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
w = iD.Way({id: 'w', nodes: ['a', 'b']}),
r = iD.Relation({id: 'r', members: [{id: 'w'}]}),
base = iD.Graph([a, b, w, r]),
head = iD.actions.CopyEntity(r, true)(base),
diff = iD.Difference(base, head),
created = diff.created();
expect(head.hasEntity('r')).to.be.ok;
expect(created).to.have.length(4);
expect(created[0]).to.be.an.instanceof(iD.Relation);
expect(created[1]).to.be.an.instanceof(iD.Way);
expect(created[2]).to.be.an.instanceof(iD.Node);
expect(created[3]).to.be.an.instanceof(iD.Node);
});
});
+24
View File
@@ -36,6 +36,30 @@ describe('iD.Entity', function () {
});
});
describe("#copy", function () {
it("returns a new Entity", function () {
var a = iD.Entity(),
result = a.copy();
expect(result).to.have.length(1);
expect(result[0]).to.be.an.instanceof(iD.Entity);
expect(a).not.to.equal(result[0]);
});
it("resets 'id', 'user', and 'version' properties", function () {
var a = iD.Entity({id: 'n1234', version: 10, user: 'bot-mode'}),
b = a.copy()[0];
expect(b.isNew()).to.be.ok;
expect(b.version).to.be.undefined;
expect(b.user).to.be.undefined;
});
it("copies tags", function () {
var a = iD.Entity({id: 'n1234', version: 10, user: 'test', tags: {foo: 'foo'}}),
b = a.copy()[0];
expect(b.tags).to.deep.equal(a.tags);
});
});
describe("#update", function () {
it("returns a new Entity", function () {
var a = iD.Entity(),
+95
View File
@@ -26,6 +26,101 @@ describe('iD.Relation', function () {
expect(iD.Relation({tags: {foo: 'bar'}}).tags).to.eql({foo: 'bar'});
});
describe("#copy", function () {
it("returns a new Relation", function () {
var r1 = iD.Relation({id: 'r1'}),
result = r1.copy(),
r2 = result[0];
expect(result).to.have.length(1);
expect(r2).to.be.an.instanceof(iD.Relation);
expect(r1).not.to.equal(r2);
});
it("keeps same members when deep = false", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
c = iD.Node({id: 'c'}),
w1 = iD.Way({id: 'w1', nodes: ['a','b','c','a']}),
r1 = iD.Relation({id: 'r1', members: [{id: 'w1', role: 'outer'}]}),
graph = iD.Graph([a, b, c, w1, r1]),
result = r1.copy(),
r1_copy = result[0];
expect(result).to.have.length(1);
expect(r1.members).to.deep.equal(r1_copy.members);
});
it("makes new members when deep = true", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
c = iD.Node({id: 'c'}),
w1 = iD.Way({id: 'w1', nodes: ['a','b','c','a']}),
r1 = iD.Relation({id: 'r1', members: [{id: 'w1', role: 'outer'}]}),
graph = iD.Graph([a, b, c, w1, r1]),
result = r1.copy(true, graph),
r1_copy = result[0];
expect(result).to.have.length(5);
expect(result[0]).to.be.an.instanceof(iD.Relation);
expect(result[1]).to.be.an.instanceof(iD.Way);
expect(result[2]).to.be.an.instanceof(iD.Node);
expect(result[3]).to.be.an.instanceof(iD.Node);
expect(result[4]).to.be.an.instanceof(iD.Node);
expect(r1_copy.members[0].id).not.to.equal(r1.members[0].id);
expect(r1_copy.members[0].role).to.equal(r1.members[0].role);
});
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'}]}),
graph = iD.Graph([w, r1, r2]),
result = r1.copy(true, graph),
r1_copy = result[0],
r2_copy = result[1],
w_copy = result[2];
expect(result).to.have.length(3);
expect(r1_copy).to.be.an.instanceof(iD.Relation);
expect(r2_copy).to.be.an.instanceof(iD.Relation);
expect(w_copy).to.be.an.instanceof(iD.Way);
expect(r1_copy.members[0].id).to.equal(r2_copy.id);
expect(r1_copy.members[1].id).to.equal(r2_copy.members[0].id);
});
// 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]),
// result = r1.copy(true, graph),
// r1_copy = result[0],
// r2_copy = result[1];
// expect(result).to.have.length(2);
// expect(r1_copy).to.be.an.instanceof(iD.Relation);
// expect(r2_copy).to.be.an.instanceof(iD.Relation);
// var msg = 'r1_copy = ' + JSON.stringify(r1_copy) +
// 'r2_copy = ' + JSON.stringify(r2_copy);
// expect(r1_copy.members[0].id).to.equal(r2_copy.id, msg);
// expect(r2_copy.members[0].id).to.equal(r1_copy.id, msg);
// });
// it("deep copies self-refrencing relations without issue", function () {
// var r1 = iD.Relation({id: 'r1', members: [{id: 'r1'}]}),
// graph = iD.Graph([r1]),
// result = r1.copy(true, graph),
// r1_copy = result[0];
// expect(result).to.have.length(1);
// expect(r1_copy).to.be.an.instanceof(iD.Relation);
// expect(r1_copy.members[0].id).to.equal(r1_copy.id);
// });
});
describe("#extent", function () {
it("returns the minimal extent containing the extents of all members", function () {
var a = iD.Node({loc: [0, 0]}),
+46
View File
@@ -26,6 +26,52 @@ describe('iD.Way', function() {
expect(iD.Way({tags: {foo: 'bar'}}).tags).to.eql({foo: 'bar'});
});
describe("#copy", function () {
it("returns a new Way", function () {
var w1 = iD.Way({id: 'w1'}),
result = w1.copy(),
w2 = result[0];
expect(result).to.have.length(1);
expect(w2).to.be.an.instanceof(iD.Way);
expect(w1).not.to.equal(w2);
});
it("keeps same nodes when deep = false", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
c = iD.Node({id: 'c'}),
w1 = iD.Entity({id: 'w1', nodes: ['a','b','c','a']}),
graph = iD.Graph([a, b, c, w1]),
result = w1.copy(),
w2 = result[0];
expect(result).to.have.length(1);
expect(w1.nodes).to.deep.equal(w2.nodes);
});
it("makes new nodes when deep = true", function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
c = iD.Node({id: 'c'}),
w1 = iD.Entity({id: 'w1', nodes: ['a','b','c','a']}),
graph = iD.Graph([a, b, c, w1]),
result = w1.copy(true, graph),
w2 = result[0];
expect(result).to.have.length(4);
expect(result[0]).to.be.an.instanceof(iD.Way);
expect(result[1]).to.be.an.instanceof(iD.Node);
expect(result[2]).to.be.an.instanceof(iD.Node);
expect(result[3]).to.be.an.instanceof(iD.Node);
expect(w2.nodes[0]).not.to.equal(w1.nodes[0]);
expect(w2.nodes[1]).not.to.equal(w1.nodes[1]);
expect(w2.nodes[2]).not.to.equal(w1.nodes[2]);
expect(w2.nodes[3]).to.equal(w2.nodes[0]);
});
});
describe("#first", function () {
it("returns the first node", function () {
expect(iD.Way({nodes: ['a', 'b', 'c']}).first()).to.equal('a');
+6
View File
@@ -30,6 +30,12 @@ describe('iD.Map', function() {
map.zoom(4);
expect(spy).not.to.have.been.called;
});
it('respects minzoom', function() {
map.minzoom(16);
map.zoom(15);
expect(map.zoom()).to.equal(16);
});
});
describe('#zoomIn', function() {