mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 05:01:38 +02:00
Upgrade legacy symbols in tests
- iD.Context -> iD.coreContext - iD.Graph -> iD.coreGraph - iD.Node -> iD.osmNode - iD.Way -> iD.osmWay - iD.Relation -> iD.osmRelation
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
describe('iD.Context', function() {
|
||||
describe('iD.coreContext', function() {
|
||||
var assets = {
|
||||
'iD/img/loader.gif': '/assets/iD/img/loader-b66184b5c4afbccc25f.gif'
|
||||
};
|
||||
|
||||
describe('#assetPath', function() {
|
||||
it('sets and gets assetPath', function() {
|
||||
var context = iD.Context();
|
||||
var context = iD.coreContext();
|
||||
expect(context.assetPath()).to.eql('');
|
||||
|
||||
context.assetPath('iD/');
|
||||
@@ -15,7 +15,7 @@ describe('iD.Context', function() {
|
||||
|
||||
describe('#assetMap', function() {
|
||||
it('sets and gets assetMap', function() {
|
||||
var context = iD.Context();
|
||||
var context = iD.coreContext();
|
||||
expect(context.assetMap()).to.eql({});
|
||||
|
||||
context.assetMap(assets);
|
||||
@@ -26,7 +26,7 @@ describe('iD.Context', function() {
|
||||
describe('#asset', function() {
|
||||
var context;
|
||||
beforeEach(function() {
|
||||
context = iD.Context().assetPath('iD/').assetMap(assets);
|
||||
context = iD.coreContext().assetPath('iD/').assetMap(assets);
|
||||
});
|
||||
|
||||
it('looks first in assetMap', function() {
|
||||
@@ -40,7 +40,7 @@ describe('iD.Context', function() {
|
||||
describe('#imagePath', function() {
|
||||
var context;
|
||||
beforeEach(function() {
|
||||
context = iD.Context().assetPath('iD/').assetMap(assets);
|
||||
context = iD.coreContext().assetPath('iD/').assetMap(assets);
|
||||
});
|
||||
|
||||
it('looks first in assetMap', function() {
|
||||
@@ -53,7 +53,7 @@ describe('iD.Context', function() {
|
||||
|
||||
describe('#debug', function() {
|
||||
it('sets and gets debug flags', function() {
|
||||
var context = iD.Context(),
|
||||
var context = iD.coreContext(),
|
||||
flags = {
|
||||
tile: false,
|
||||
collision: false,
|
||||
|
||||
@@ -1,92 +1,92 @@
|
||||
describe('iD.Difference', function () {
|
||||
describe('#changes', function () {
|
||||
it('includes created entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({n: {base: undefined, head: node}});
|
||||
});
|
||||
|
||||
it('includes undone created entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node),
|
||||
diff = iD.Difference(head, base);
|
||||
expect(diff.changes()).to.eql({n: {base: node, head: undefined}});
|
||||
});
|
||||
|
||||
it('includes modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({ tags: { yes: 'no' } }),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({n: {base: n1, head: n2}});
|
||||
});
|
||||
|
||||
it('includes undone modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({ tags: { yes: 'no' } }),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(head, base);
|
||||
expect(diff.changes()).to.eql({n: {base: n2, head: n1}});
|
||||
});
|
||||
|
||||
it('doesn\'t include updated but identical entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update(),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({});
|
||||
});
|
||||
|
||||
it('includes deleted entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({n: {base: node, head: undefined}});
|
||||
});
|
||||
|
||||
it('includes undone deleted entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node),
|
||||
diff = iD.Difference(head, base);
|
||||
expect(diff.changes()).to.eql({n: {base: undefined, head: node}});
|
||||
});
|
||||
|
||||
it('doesn\'t include created entities that were subsequently deleted', function () {
|
||||
var node = iD.Node(),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode(),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node).remove(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({});
|
||||
});
|
||||
|
||||
it('doesn\'t include created entities that were subsequently reverted', function () {
|
||||
var node = iD.Node({id: 'n-1'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n-1'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node).revert('n-1'),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({});
|
||||
});
|
||||
|
||||
it('doesn\'t include modified entities that were subsequently reverted', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({ tags: { yes: 'no' } }),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2).revert('n'),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({});
|
||||
});
|
||||
|
||||
it('doesn\'t include deleted entities that were subsequently reverted', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node).revert('n'),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.changes()).to.eql({});
|
||||
@@ -95,25 +95,25 @@ describe('iD.Difference', function () {
|
||||
|
||||
describe('#extantIDs', function () {
|
||||
it('includes the ids of created entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.extantIDs()).to.eql(['n']);
|
||||
});
|
||||
|
||||
it('includes the ids of modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.extantIDs()).to.eql(['n']);
|
||||
});
|
||||
|
||||
it('omits the ids of deleted entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.extantIDs()).to.eql([]);
|
||||
@@ -122,8 +122,8 @@ describe('iD.Difference', function () {
|
||||
|
||||
describe('#created', function () {
|
||||
it('returns an array of created entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.created()).to.eql([node]);
|
||||
@@ -132,9 +132,9 @@ describe('iD.Difference', function () {
|
||||
|
||||
describe('#modified', function () {
|
||||
it('returns an array of modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.modified()).to.eql([n2]);
|
||||
@@ -143,8 +143,8 @@ describe('iD.Difference', function () {
|
||||
|
||||
describe('#deleted', function () {
|
||||
it('returns an array of deleted entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.deleted()).to.eql([node]);
|
||||
@@ -152,15 +152,15 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
describe('#summary', function () {
|
||||
var base = iD.Graph([
|
||||
iD.Node({id: 'a', tags: {crossing: 'marked'}}),
|
||||
iD.Node({id: 'b'}),
|
||||
iD.Node({id: 'v'}),
|
||||
iD.Way({id: '-', nodes: ['a', 'b']})
|
||||
var base = iD.coreGraph([
|
||||
iD.osmNode({id: 'a', tags: {crossing: 'marked'}}),
|
||||
iD.osmNode({id: 'b'}),
|
||||
iD.osmNode({id: 'v'}),
|
||||
iD.osmWay({id: '-', nodes: ['a', 'b']})
|
||||
]);
|
||||
|
||||
it('reports a created way as created', function() {
|
||||
var way = iD.Way({id: '+'}),
|
||||
var way = iD.osmWay({id: '+'}),
|
||||
head = base.replace(way),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -208,7 +208,7 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('reports a way as modified when a member vertex is added', function() {
|
||||
var vertex = iD.Node({id: 'c'}),
|
||||
var vertex = iD.osmNode({id: 'c'}),
|
||||
way = base.entity('-').addNode('c'),
|
||||
head = base.replace(vertex).replace(way),
|
||||
diff = iD.Difference(base, head);
|
||||
@@ -234,7 +234,7 @@ describe('iD.Difference', function () {
|
||||
|
||||
it('reports a created way containing a moved vertex as being created', function() {
|
||||
var vertex = base.entity('b').move([0,3]),
|
||||
way = iD.Way({id: '+', nodes: ['b']}),
|
||||
way = iD.osmWay({id: '+', nodes: ['b']}),
|
||||
head = base.replace(way).replace(vertex),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -250,8 +250,8 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('reports a created way with a created vertex as being created', function() {
|
||||
var vertex = iD.Node({id: 'c'}),
|
||||
way = iD.Way({id: '+', nodes: ['c']}),
|
||||
var vertex = iD.osmNode({id: 'c'}),
|
||||
way = iD.osmWay({id: '+', nodes: ['c']}),
|
||||
head = base.replace(vertex).replace(way),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -315,7 +315,7 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('reports a vertex as created when it has tags', function() {
|
||||
var vertex = iD.Node({id: 'c', tags: {crossing: 'marked'}}),
|
||||
var vertex = iD.osmNode({id: 'c', tags: {crossing: 'marked'}}),
|
||||
way = base.entity('-').addNode('c'),
|
||||
head = base.replace(way).replace(vertex),
|
||||
diff = iD.Difference(base, head);
|
||||
@@ -334,36 +334,36 @@ describe('iD.Difference', function () {
|
||||
|
||||
describe('#complete', function () {
|
||||
it('includes created entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph(),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph(),
|
||||
head = base.replace(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.complete().n).to.equal(node);
|
||||
});
|
||||
|
||||
it('includes modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
base = iD.Graph([n1]),
|
||||
base = iD.coreGraph([n1]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.complete().n).to.equal(n2);
|
||||
});
|
||||
|
||||
it('includes deleted entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
base = iD.Graph([node]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
base = iD.coreGraph([node]),
|
||||
head = base.remove(node),
|
||||
diff = iD.Difference(base, head);
|
||||
expect(diff.complete()).to.eql({n: undefined});
|
||||
});
|
||||
|
||||
it('includes nodes added to a way', function () {
|
||||
var n1 = iD.Node({id: 'n1'}),
|
||||
n2 = iD.Node({id: 'n2'}),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n1']}),
|
||||
var n1 = iD.osmNode({id: 'n1'}),
|
||||
n2 = iD.osmNode({id: 'n2'}),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n1']}),
|
||||
w2 = w1.addNode('n2'),
|
||||
base = iD.Graph([n1, n2, w1]),
|
||||
base = iD.coreGraph([n1, n2, w1]),
|
||||
head = base.replace(w2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -371,11 +371,11 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('includes nodes removed from a way', function () {
|
||||
var n1 = iD.Node({id: 'n1'}),
|
||||
n2 = iD.Node({id: 'n2'}),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n1', 'n2']}),
|
||||
var n1 = iD.osmNode({id: 'n1'}),
|
||||
n2 = iD.osmNode({id: 'n2'}),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n1', 'n2']}),
|
||||
w2 = w1.removeNode('n2'),
|
||||
base = iD.Graph([n1, n2, w1]),
|
||||
base = iD.coreGraph([n1, n2, w1]),
|
||||
head = base.replace(w2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -383,10 +383,10 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('includes parent ways of modified nodes', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
way = iD.Way({id: 'w', nodes: ['n']}),
|
||||
base = iD.Graph([n1, way]),
|
||||
way = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
base = iD.coreGraph([n1, way]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -394,10 +394,10 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('includes parent relations of modified entities', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
rel = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
base = iD.Graph([n1, rel]),
|
||||
rel = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
base = iD.coreGraph([n1, rel]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -405,11 +405,11 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('includes parent relations of modified entities, recursively', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
rel1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
rel2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
base = iD.Graph([n1, rel1, rel2]),
|
||||
rel1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
rel2 = iD.osmRelation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
base = iD.coreGraph([n1, rel1, rel2]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -417,11 +417,11 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('includes parent relations of parent ways of modified nodes', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.move([1, 2]),
|
||||
way = iD.Way({id: 'w', nodes: ['n']}),
|
||||
rel = iD.Relation({id: 'r', members: [{id: 'w'}]}),
|
||||
base = iD.Graph([n1, way, rel]),
|
||||
way = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
rel = iD.osmRelation({id: 'r', members: [{id: 'w'}]}),
|
||||
base = iD.coreGraph([n1, way, rel]),
|
||||
head = base.replace(n2),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
@@ -429,10 +429,10 @@ describe('iD.Difference', function () {
|
||||
});
|
||||
|
||||
it('copes with recursive relations', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
rel1 = iD.Relation({id: 'r1', members: [{id: 'n'}, {id: 'r2'}]}),
|
||||
rel2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
base = iD.Graph([node, rel1, rel2]),
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
rel1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}, {id: 'r2'}]}),
|
||||
rel2 = iD.osmRelation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
base = iD.coreGraph([node, rel1, rel2]),
|
||||
head = base.replace(node.move([1, 2])),
|
||||
diff = iD.Difference(base, head);
|
||||
|
||||
|
||||
+158
-158
@@ -1,67 +1,67 @@
|
||||
describe('iD.Graph', function() {
|
||||
describe('iD.coreGraph', function() {
|
||||
describe('constructor', function () {
|
||||
it('accepts an entities Array', function () {
|
||||
var entity = iD.Entity(),
|
||||
graph = iD.Graph([entity]);
|
||||
graph = iD.coreGraph([entity]);
|
||||
expect(graph.entity(entity.id)).to.equal(entity);
|
||||
});
|
||||
|
||||
it('accepts a Graph', function () {
|
||||
var entity = iD.Entity(),
|
||||
graph = iD.Graph(iD.Graph([entity]));
|
||||
graph = iD.coreGraph(iD.coreGraph([entity]));
|
||||
expect(graph.entity(entity.id)).to.equal(entity);
|
||||
});
|
||||
|
||||
it('copies other\'s entities', function () {
|
||||
var entity = iD.Entity(),
|
||||
base = iD.Graph([entity]),
|
||||
graph = iD.Graph(base);
|
||||
base = iD.coreGraph([entity]),
|
||||
graph = iD.coreGraph(base);
|
||||
expect(graph.entities).not.to.equal(base.entities);
|
||||
});
|
||||
|
||||
it('rebases on other\'s base', function () {
|
||||
var base = iD.Graph(),
|
||||
graph = iD.Graph(base);
|
||||
var base = iD.coreGraph(),
|
||||
graph = iD.coreGraph(base);
|
||||
expect(graph.base().entities).to.equal(base.base().entities);
|
||||
});
|
||||
|
||||
it('freezes by default', function () {
|
||||
expect(iD.Graph().frozen).to.be.true;
|
||||
expect(iD.coreGraph().frozen).to.be.true;
|
||||
});
|
||||
|
||||
it('remains mutable if passed true as second argument', function () {
|
||||
expect(iD.Graph([], true).frozen).to.be.false;
|
||||
expect(iD.coreGraph([], true).frozen).to.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
describe('#hasEntity', function () {
|
||||
it('returns the entity when present', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.hasEntity(node.id)).to.equal(node);
|
||||
});
|
||||
|
||||
it('returns undefined when the entity is not present', function () {
|
||||
expect(iD.Graph().hasEntity('1')).to.be.undefined;
|
||||
expect(iD.coreGraph().hasEntity('1')).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('#entity', function () {
|
||||
it('returns the entity when present', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.entity(node.id)).to.equal(node);
|
||||
});
|
||||
|
||||
it('throws when the entity is not present', function () {
|
||||
expect(function() { iD.Graph().entity('1'); }).to.throw;
|
||||
expect(function() { iD.coreGraph().entity('1'); }).to.throw;
|
||||
});
|
||||
});
|
||||
|
||||
describe('#rebase', function () {
|
||||
it('preserves existing entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph([node]);
|
||||
|
||||
graph.rebase([], [graph]);
|
||||
|
||||
@@ -69,8 +69,8 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('includes new entities', function () {
|
||||
var node = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph();
|
||||
var node = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph();
|
||||
|
||||
graph.rebase([node], [graph]);
|
||||
|
||||
@@ -78,8 +78,8 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('doesn\'t rebase deleted entities', function () {
|
||||
var node = iD.Node({id: 'n', visible: false}),
|
||||
graph = iD.Graph();
|
||||
var node = iD.osmNode({id: 'n', visible: false}),
|
||||
graph = iD.coreGraph();
|
||||
|
||||
graph.rebase([node], [graph]);
|
||||
|
||||
@@ -87,9 +87,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('gives precedence to existing entities', function () {
|
||||
var a = iD.Node({id: 'n'}),
|
||||
b = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph([a]);
|
||||
var a = iD.osmNode({id: 'n'}),
|
||||
b = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph([a]);
|
||||
|
||||
graph.rebase([b], [graph]);
|
||||
|
||||
@@ -97,9 +97,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('gives precedence to new entities when force = true', function () {
|
||||
var a = iD.Node({id: 'n'}),
|
||||
b = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph([a]);
|
||||
var a = iD.osmNode({id: 'n'}),
|
||||
b = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph([a]);
|
||||
|
||||
graph.rebase([b], [graph], true);
|
||||
|
||||
@@ -107,18 +107,18 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('inherits entities from base prototypally', function () {
|
||||
var graph = iD.Graph();
|
||||
var graph = iD.coreGraph();
|
||||
|
||||
graph.rebase([iD.Node({id: 'n'})], [graph]);
|
||||
graph.rebase([iD.osmNode({id: 'n'})], [graph]);
|
||||
|
||||
expect(graph.entities).not.to.have.ownProperty('n');
|
||||
});
|
||||
|
||||
it('updates parentWays', function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.Way({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]);
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.osmWay({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]);
|
||||
|
||||
graph.rebase([w2], [graph]);
|
||||
|
||||
@@ -127,9 +127,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('avoids adding duplicate parentWays', function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]);
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]);
|
||||
|
||||
graph.rebase([w1], [graph]);
|
||||
|
||||
@@ -137,11 +137,11 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('updates parentWays for nodes with modified parentWays', function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.Way({id: 'w2', nodes: ['n']}),
|
||||
w3 = iD.Way({id: 'w3', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.osmWay({id: 'w2', nodes: ['n']}),
|
||||
w3 = iD.osmWay({id: 'w3', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]),
|
||||
graph2 = graph.replace(w2);
|
||||
|
||||
graph.rebase([w3], [graph, graph2]);
|
||||
@@ -150,11 +150,11 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('avoids re-adding a modified way as a parent way', function() {
|
||||
var n1 = iD.Node({id: 'n1'}),
|
||||
n2 = iD.Node({id: 'n2'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n1', 'n2']}),
|
||||
var n1 = iD.osmNode({id: 'n1'}),
|
||||
n2 = iD.osmNode({id: 'n2'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n1', 'n2']}),
|
||||
w2 = w1.removeNode('n2'),
|
||||
graph = iD.Graph([n1, n2, w1]),
|
||||
graph = iD.coreGraph([n1, n2, w1]),
|
||||
graph2 = graph.replace(w2);
|
||||
|
||||
graph.rebase([w1], [graph, graph2]);
|
||||
@@ -163,9 +163,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('avoids re-adding a deleted way as a parent way', function() {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]),
|
||||
graph2 = graph.remove(w1);
|
||||
|
||||
graph.rebase([w1], [graph, graph2]);
|
||||
@@ -174,10 +174,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('re-adds a deleted node that is discovered to have another parent', function() {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.Way({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.osmWay({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]),
|
||||
graph2 = graph.remove(n);
|
||||
|
||||
graph.rebase([n, w2], [graph, graph2]);
|
||||
@@ -186,10 +186,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('updates parentRelations', function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.Relation({id: 'r2', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([n, r1]);
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.osmRelation({id: 'r2', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([n, r1]);
|
||||
|
||||
graph.rebase([r2], [graph]);
|
||||
|
||||
@@ -198,10 +198,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('avoids re-adding a modified relation as a parent relation', function() {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = r1.removeMembersWithID('n'),
|
||||
graph = iD.Graph([n, r1]),
|
||||
graph = iD.coreGraph([n, r1]),
|
||||
graph2 = graph.replace(r2);
|
||||
|
||||
graph.rebase([r1], [graph, graph2]);
|
||||
@@ -210,9 +210,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('avoids re-adding a deleted relation as a parent relation', function() {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([n, r1]),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([n, r1]),
|
||||
graph2 = graph.remove(r1);
|
||||
|
||||
graph.rebase([r1], [graph, graph2]);
|
||||
@@ -221,11 +221,11 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('updates parentRels for nodes with modified parentWays', function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.Relation({id: 'r2', members: [{id: 'n'}]}),
|
||||
r3 = iD.Relation({id: 'r3', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([n, r1]),
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.osmRelation({id: 'r2', members: [{id: 'n'}]}),
|
||||
r3 = iD.osmRelation({id: 'r3', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([n, r1]),
|
||||
graph2 = graph.replace(r2);
|
||||
|
||||
graph.rebase([r3], [graph, graph2]);
|
||||
@@ -234,10 +234,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('invalidates transients', function() {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.Way({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.Graph([n, w1]);
|
||||
var n = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w1', nodes: ['n']}),
|
||||
w2 = iD.osmWay({id: 'w2', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n, w1]);
|
||||
|
||||
function numParents(entity) {
|
||||
return graph.transient(entity, 'numParents', function() {
|
||||
@@ -253,160 +253,160 @@ describe('iD.Graph', function() {
|
||||
|
||||
describe('#remove', function () {
|
||||
it('returns a new graph', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.remove(node)).not.to.equal(graph);
|
||||
});
|
||||
|
||||
it('doesn\'t modify the receiver', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
graph.remove(node);
|
||||
expect(graph.entity(node.id)).to.equal(node);
|
||||
});
|
||||
|
||||
it('removes the entity from the result', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.remove(node).hasEntity(node.id)).to.be.undefined;
|
||||
});
|
||||
|
||||
it('removes the entity as a parentWay', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph([node, w1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph([node, w1]);
|
||||
expect(graph.remove(w1).parentWays(node)).to.eql([]);
|
||||
});
|
||||
|
||||
it('removes the entity as a parentRelation', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
r1 = iD.Relation({id: 'w', members: [{id: 'n' }]}),
|
||||
graph = iD.Graph([node, r1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
r1 = iD.osmRelation({id: 'w', members: [{id: 'n' }]}),
|
||||
graph = iD.coreGraph([node, r1]);
|
||||
expect(graph.remove(r1).parentRelations(node)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#replace', function () {
|
||||
it('is a no-op if the replacement is identical to the existing entity', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.replace(node)).to.equal(graph);
|
||||
});
|
||||
|
||||
it('returns a new graph', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.replace(node.update())).not.to.equal(graph);
|
||||
});
|
||||
|
||||
it('doesn\'t modify the receiver', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
graph.replace(node);
|
||||
expect(graph.entity(node.id)).to.equal(node);
|
||||
});
|
||||
|
||||
it('replaces the entity in the result', function () {
|
||||
var node1 = iD.Node(),
|
||||
var node1 = iD.osmNode(),
|
||||
node2 = node1.update({}),
|
||||
graph = iD.Graph([node1]);
|
||||
graph = iD.coreGraph([node1]);
|
||||
expect(graph.replace(node2).entity(node2.id)).to.equal(node2);
|
||||
});
|
||||
|
||||
it('adds parentWays', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.replace(w1).parentWays(node)).to.eql([w1]);
|
||||
});
|
||||
|
||||
it('removes parentWays', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph([node, w1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph([node, w1]);
|
||||
expect(graph.remove(w1).parentWays(node)).to.eql([]);
|
||||
});
|
||||
|
||||
it('doesn\'t add duplicate parentWays', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph([node, w1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph([node, w1]);
|
||||
expect(graph.replace(w1).parentWays(node)).to.eql([w1]);
|
||||
});
|
||||
|
||||
it('adds parentRelations', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([node]);
|
||||
expect(graph.replace(r1).parentRelations(node)).to.eql([r1]);
|
||||
});
|
||||
|
||||
it('removes parentRelations', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([node, r1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([node, r1]);
|
||||
expect(graph.remove(r1).parentRelations(node)).to.eql([]);
|
||||
});
|
||||
|
||||
it('doesn\'t add duplicate parentRelations', function () {
|
||||
var node = iD.Node({id: 'n' }),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([node, r1]);
|
||||
var node = iD.osmNode({id: 'n' }),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([node, r1]);
|
||||
expect(graph.replace(r1).parentRelations(node)).to.eql([r1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#revert', function () {
|
||||
it('is a no-op if the head entity is identical to the base entity', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph([n1]);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph([n1]);
|
||||
expect(graph.revert('n')).to.equal(graph);
|
||||
});
|
||||
|
||||
it('returns a new graph', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({}),
|
||||
graph = iD.Graph([n1]).replace(n2);
|
||||
graph = iD.coreGraph([n1]).replace(n2);
|
||||
expect(graph.revert('n')).not.to.equal(graph);
|
||||
});
|
||||
|
||||
it('doesn\'t modify the receiver', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({}),
|
||||
graph = iD.Graph([n1]).replace(n2);
|
||||
graph = iD.coreGraph([n1]).replace(n2);
|
||||
graph.revert('n');
|
||||
expect(graph.hasEntity('n')).to.equal(n2);
|
||||
});
|
||||
|
||||
it('removes a new entity', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph().replace(n1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph().replace(n1);
|
||||
|
||||
graph = graph.revert('n');
|
||||
expect(graph.hasEntity('n')).to.be.undefined;
|
||||
});
|
||||
|
||||
it('reverts an updated entity to the base version', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
n2 = n1.update({}),
|
||||
graph = iD.Graph([n1]).replace(n2);
|
||||
graph = iD.coreGraph([n1]).replace(n2);
|
||||
|
||||
graph = graph.revert('n');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
});
|
||||
|
||||
it('restores a deleted entity', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
graph = iD.Graph([n1]).remove(n1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
graph = iD.coreGraph([n1]).remove(n1);
|
||||
|
||||
graph = graph.revert('n');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
});
|
||||
|
||||
it('removes new parentWays', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph().replace(n1).replace(w1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph().replace(n1).replace(w1);
|
||||
|
||||
graph = graph.revert('w');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -414,9 +414,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('removes new parentRelations', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph().replace(n1).replace(r1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph().replace(n1).replace(r1);
|
||||
|
||||
graph = graph.revert('r');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -424,10 +424,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('reverts updated parentWays', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
w2 = w1.removeNode('n'),
|
||||
graph = iD.Graph([n1, w1]).replace(w2);
|
||||
graph = iD.coreGraph([n1, w1]).replace(w2);
|
||||
|
||||
graph = graph.revert('w');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -435,10 +435,10 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('reverts updated parentRelations', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
r2 = r1.removeMembersWithID('n'),
|
||||
graph = iD.Graph([n1, r1]).replace(r2);
|
||||
graph = iD.coreGraph([n1, r1]).replace(r2);
|
||||
|
||||
graph = graph.revert('r');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -446,9 +446,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('restores deleted parentWays', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
w1 = iD.Way({id: 'w', nodes: ['n']}),
|
||||
graph = iD.Graph([n1, w1]).remove(w1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
w1 = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
graph = iD.coreGraph([n1, w1]).remove(w1);
|
||||
|
||||
graph = graph.revert('w');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -456,9 +456,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('restores deleted parentRelations', function () {
|
||||
var n1 = iD.Node({id: 'n'}),
|
||||
r1 = iD.Relation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.Graph([n1, r1]).remove(r1);
|
||||
var n1 = iD.osmNode({id: 'n'}),
|
||||
r1 = iD.osmRelation({id: 'r', members: [{id: 'n'}]}),
|
||||
graph = iD.coreGraph([n1, r1]).remove(r1);
|
||||
|
||||
graph = graph.revert('r');
|
||||
expect(graph.hasEntity('n')).to.equal(n1);
|
||||
@@ -468,18 +468,18 @@ describe('iD.Graph', function() {
|
||||
|
||||
describe('#update', function () {
|
||||
it('returns a new graph if self is frozen', function () {
|
||||
var graph = iD.Graph();
|
||||
var graph = iD.coreGraph();
|
||||
expect(graph.update()).not.to.equal(graph);
|
||||
});
|
||||
|
||||
it('returns self if self is not frozen', function () {
|
||||
var graph = iD.Graph([], true);
|
||||
var graph = iD.coreGraph([], true);
|
||||
expect(graph.update()).to.equal(graph);
|
||||
});
|
||||
|
||||
it('doesn\'t modify self is self is frozen', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node]);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node]);
|
||||
|
||||
graph.update(function (graph) { graph.remove(node); });
|
||||
|
||||
@@ -487,8 +487,8 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('modifies self is self is not frozen', function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.Graph([node], true);
|
||||
var node = iD.osmNode(),
|
||||
graph = iD.coreGraph([node], true);
|
||||
|
||||
graph.update(function (graph) { graph.remove(node); });
|
||||
|
||||
@@ -496,9 +496,9 @@ describe('iD.Graph', function() {
|
||||
});
|
||||
|
||||
it('executes all of the given functions', function () {
|
||||
var a = iD.Node(),
|
||||
b = iD.Node(),
|
||||
graph = iD.Graph([a]);
|
||||
var a = iD.osmNode(),
|
||||
b = iD.osmNode(),
|
||||
graph = iD.coreGraph([a]);
|
||||
|
||||
graph = graph.update(
|
||||
function (graph) { graph.remove(a); },
|
||||
@@ -512,9 +512,9 @@ describe('iD.Graph', function() {
|
||||
|
||||
describe('#parentWays', function() {
|
||||
it('returns an array of ways that contain the given node id', function () {
|
||||
var node = iD.Node({id: 'n1'}),
|
||||
way = iD.Way({id: 'w1', nodes: ['n1']}),
|
||||
graph = iD.Graph([node, way]);
|
||||
var node = iD.osmNode({id: 'n1'}),
|
||||
way = iD.osmWay({id: 'w1', nodes: ['n1']}),
|
||||
graph = iD.coreGraph([node, way]);
|
||||
expect(graph.parentWays(node)).to.eql([way]);
|
||||
expect(graph.parentWays(way)).to.eql([]);
|
||||
});
|
||||
@@ -522,10 +522,10 @@ 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'}),
|
||||
relation = iD.Relation({id: 'r1', members: [{ id: 'n1', role: 'from' }]}),
|
||||
graph = iD.Graph([node, relation]);
|
||||
var node = iD.osmNode({id: 'n1'}),
|
||||
nonnode = iD.osmNode({id: 'n2'}),
|
||||
relation = iD.osmRelation({id: 'r1', members: [{ id: 'n1', role: 'from' }]}),
|
||||
graph = iD.coreGraph([node, relation]);
|
||||
expect(graph.parentRelations(node)).to.eql([relation]);
|
||||
expect(graph.parentRelations(nonnode)).to.eql([]);
|
||||
});
|
||||
@@ -533,9 +533,9 @@ describe('iD.Graph', function() {
|
||||
|
||||
describe('#childNodes', function () {
|
||||
it('returns an array of child nodes', function () {
|
||||
var node = iD.Node({id: 'n1'}),
|
||||
way = iD.Way({id: 'w1', nodes: ['n1']}),
|
||||
graph = iD.Graph([node, way]);
|
||||
var node = iD.osmNode({id: 'n1'}),
|
||||
way = iD.osmWay({id: 'w1', nodes: ['n1']}),
|
||||
graph = iD.coreGraph([node, way]);
|
||||
expect(graph.childNodes(way)).to.eql([node]);
|
||||
});
|
||||
});
|
||||
|
||||
+32
-32
@@ -1,9 +1,9 @@
|
||||
describe('iD.History', function () {
|
||||
var context, history, spy,
|
||||
action = function() { return iD.Graph(); };
|
||||
action = function() { return iD.coreGraph(); };
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD.Context();
|
||||
context = iD.coreContext();
|
||||
history = context.history();
|
||||
spy = sinon.spy();
|
||||
// clear lock
|
||||
@@ -12,13 +12,13 @@ describe('iD.History', function () {
|
||||
|
||||
describe('#graph', function () {
|
||||
it('returns the current graph', function () {
|
||||
expect(history.graph()).to.be.an.instanceOf(iD.Graph);
|
||||
expect(history.graph()).to.be.an.instanceOf(iD.coreGraph);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#merge', function () {
|
||||
it('merges the entities into all graph versions', function () {
|
||||
var n = iD.Node({id: 'n'});
|
||||
var n = iD.osmNode({id: 'n'});
|
||||
history.merge([n]);
|
||||
expect(history.graph().entity('n')).to.equal(n);
|
||||
});
|
||||
@@ -37,7 +37,7 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('updates the graph', function () {
|
||||
var node = iD.Node();
|
||||
var node = iD.osmNode();
|
||||
history.perform(function (graph) { return graph.replace(node); });
|
||||
expect(history.graph().entity(node.id)).to.equal(node);
|
||||
});
|
||||
@@ -55,8 +55,8 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('performs multiple actions', function () {
|
||||
var action1 = sinon.stub().returns(iD.Graph()),
|
||||
action2 = sinon.stub().returns(iD.Graph());
|
||||
var action1 = sinon.stub().returns(iD.coreGraph()),
|
||||
action2 = sinon.stub().returns(iD.coreGraph());
|
||||
history.perform(action1, action2, 'annotation');
|
||||
expect(action1).to.have.been.called;
|
||||
expect(action2).to.have.been.called;
|
||||
@@ -64,7 +64,7 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('performs transitionable actions in a transition', function (done) {
|
||||
var action1 = function() { return iD.Graph(); };
|
||||
var action1 = function() { return iD.coreGraph(); };
|
||||
action1.transitionable = true;
|
||||
history.on('change', spy);
|
||||
history.perform(action1);
|
||||
@@ -81,7 +81,7 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('updates the graph', function () {
|
||||
var node = iD.Node();
|
||||
var node = iD.osmNode();
|
||||
history.replace(function (graph) { return graph.replace(node); });
|
||||
expect(history.graph().entity(node.id)).to.equal(node);
|
||||
});
|
||||
@@ -99,8 +99,8 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('performs multiple actions', function () {
|
||||
var action1 = sinon.stub().returns(iD.Graph()),
|
||||
action2 = sinon.stub().returns(iD.Graph());
|
||||
var action1 = sinon.stub().returns(iD.coreGraph()),
|
||||
action2 = sinon.stub().returns(iD.coreGraph());
|
||||
history.replace(action1, action2, 'annotation');
|
||||
expect(action1).to.have.been.called;
|
||||
expect(action2).to.have.been.called;
|
||||
@@ -168,7 +168,7 @@ describe('iD.History', function () {
|
||||
|
||||
it('updates the graph', function () {
|
||||
history.perform(action, 'annotation');
|
||||
var node = iD.Node();
|
||||
var node = iD.osmNode();
|
||||
history.overwrite(function (graph) { return graph.replace(node); });
|
||||
expect(history.graph().entity(node.id)).to.equal(node);
|
||||
});
|
||||
@@ -193,8 +193,8 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('performs multiple actions', function () {
|
||||
var action1 = sinon.stub().returns(iD.Graph()),
|
||||
action2 = sinon.stub().returns(iD.Graph());
|
||||
var action1 = sinon.stub().returns(iD.coreGraph()),
|
||||
action2 = sinon.stub().returns(iD.coreGraph());
|
||||
history.perform(action, 'annotation');
|
||||
history.overwrite(action1, action2, 'annotation2');
|
||||
expect(action1).to.have.been.called;
|
||||
@@ -268,13 +268,13 @@ describe('iD.History', function () {
|
||||
|
||||
describe('#changes', function () {
|
||||
it('includes created entities', function () {
|
||||
var node = iD.Node();
|
||||
var node = iD.osmNode();
|
||||
history.perform(function (graph) { return graph.replace(node); });
|
||||
expect(history.changes().created).to.eql([node]);
|
||||
});
|
||||
|
||||
it('includes modified entities', function () {
|
||||
var node1 = iD.Node({id: 'n1'}),
|
||||
var node1 = iD.osmNode({id: 'n1'}),
|
||||
node2 = node1.update({ tags: { yes: 'no' } });
|
||||
history.merge([node1]);
|
||||
history.perform(function (graph) { return graph.replace(node2); });
|
||||
@@ -282,7 +282,7 @@ describe('iD.History', function () {
|
||||
});
|
||||
|
||||
it('includes deleted entities', function () {
|
||||
var node = iD.Node({id: 'n1'});
|
||||
var node = iD.osmNode({id: 'n1'});
|
||||
history.merge([node]);
|
||||
history.perform(function (graph) { return graph.remove(node); });
|
||||
expect(history.changes().deleted).to.eql([node]);
|
||||
@@ -291,7 +291,7 @@ describe('iD.History', function () {
|
||||
|
||||
describe('#hasChanges', function() {
|
||||
it('is true when any of change\'s values are nonempty', function() {
|
||||
var node = iD.Node();
|
||||
var node = iD.osmNode();
|
||||
history.perform(function (graph) { return graph.replace(node); });
|
||||
expect(history.hasChanges()).to.eql(true);
|
||||
});
|
||||
@@ -350,17 +350,17 @@ describe('iD.History', function () {
|
||||
|
||||
describe('#toJSON', function() {
|
||||
it('doesn\'t generate unsaveable changes', function() {
|
||||
var node_1 = iD.Node({id: 'n-1'});
|
||||
var node_1 = iD.osmNode({id: 'n-1'});
|
||||
history.perform(iD.actionAddEntity(node_1));
|
||||
history.perform(iD.actionDeleteNode('n-1'));
|
||||
expect(history.toJSON()).to.be.not.ok;
|
||||
});
|
||||
|
||||
it('generates v3 JSON', function() {
|
||||
var node_1 = iD.Node({id: 'n-1'}),
|
||||
node1 = iD.Node({id: 'n1'}),
|
||||
node2 = iD.Node({id: 'n2'}),
|
||||
node3 = iD.Node({id: 'n3'});
|
||||
var node_1 = iD.osmNode({id: 'n-1'}),
|
||||
node1 = iD.osmNode({id: 'n1'}),
|
||||
node2 = iD.osmNode({id: 'n2'}),
|
||||
node3 = iD.osmNode({id: 'n3'});
|
||||
history.merge([node1, node2, node3]);
|
||||
history.perform(iD.actionAddEntity(node_1)); // addition
|
||||
history.perform(iD.actionChangeTags('n2', {k: 'v'})); // modification
|
||||
@@ -397,7 +397,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.osmNode({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.undoAnnotation()).to.eql('Added a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
@@ -414,7 +414,7 @@ describe('iD.History', function () {
|
||||
'index': 2
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [2, 3], v: 1}));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.osmNode({id: 'n-1', loc: [2, 3], v: 1}));
|
||||
expect(history.undoAnnotation()).to.eql('Moved a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
@@ -430,7 +430,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
history.merge([iD.Node({id: 'n1'})]);
|
||||
history.merge([iD.osmNode({id: 'n1'})]);
|
||||
expect(history.graph().hasEntity('n1')).to.be.undefined;
|
||||
expect(history.undoAnnotation()).to.eql('Deleted a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
@@ -451,7 +451,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.osmNode({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.undoAnnotation()).to.eql('Added a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
@@ -472,8 +472,8 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
history.merge([iD.Node({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135)
|
||||
expect(history.graph().entity('n1')).to.eql(iD.Node({id: 'n1', loc: [2, 3], v: 1}));
|
||||
history.merge([iD.osmNode({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135)
|
||||
expect(history.graph().entity('n1')).to.eql(iD.osmNode({id: 'n1', loc: [2, 3], v: 1}));
|
||||
expect(history.undoAnnotation()).to.eql('Moved a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
@@ -492,7 +492,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
history.merge([iD.Node({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135)
|
||||
history.merge([iD.osmNode({id: 'n1'})]); // Shouldn't be necessary; flaw in v2 format (see #2135)
|
||||
expect(history.graph().hasEntity('n1')).to.be.undefined;
|
||||
expect(history.undoAnnotation()).to.eql('Deleted a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
@@ -515,7 +515,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.Node({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.graph().entity('n-1')).to.eql(iD.osmNode({id: 'n-1', loc: [1, 2]}));
|
||||
expect(history.undoAnnotation()).to.eql('Added a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
@@ -537,7 +537,7 @@ describe('iD.History', function () {
|
||||
'index': 1
|
||||
};
|
||||
history.fromJSON(JSON.stringify(json));
|
||||
expect(history.graph().entity('n1')).to.eql(iD.Node({id: 'n1', loc: [2, 3], v: 1}));
|
||||
expect(history.graph().entity('n1')).to.eql(iD.osmNode({id: 'n1', loc: [2, 3], v: 1}));
|
||||
expect(history.undoAnnotation()).to.eql('Moved a point.');
|
||||
expect(history.imageryUsed()).to.eql(['Bing']);
|
||||
expect(iD.Entity.id.next).to.eql({node: -2, way: -1, relation: -1});
|
||||
|
||||
+47
-47
@@ -1,9 +1,9 @@
|
||||
describe('iD.Tree', function() {
|
||||
describe('#rebase', function() {
|
||||
it('adds entities to the tree', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]});
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]});
|
||||
|
||||
graph.rebase([node], [graph]);
|
||||
tree.rebase([node]);
|
||||
@@ -12,9 +12,9 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('is idempotent', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph.rebase([node], [graph]);
|
||||
@@ -27,9 +27,9 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('does not insert if entity has a modified version', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
node_ = node.update({loc: [10, 10]}),
|
||||
g = graph.replace(node_);
|
||||
|
||||
@@ -43,10 +43,10 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('does not error on self-referencing relations', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
relation = iD.Relation();
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
relation = iD.osmRelation();
|
||||
|
||||
relation = relation.addMember({id: node.id});
|
||||
relation = relation.addMember({id: relation.id});
|
||||
@@ -58,9 +58,9 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('adjusts entities that are force-rebased', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]});
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]});
|
||||
|
||||
graph.rebase([node], [graph]);
|
||||
tree.rebase([node]);
|
||||
@@ -75,10 +75,10 @@ describe('iD.Tree', function() {
|
||||
|
||||
describe('#intersects', function() {
|
||||
it('includes entities within extent, excludes those without', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
n1 = iD.Node({loc: [1, 1]}),
|
||||
n2 = iD.Node({loc: [3, 3]}),
|
||||
n1 = iD.osmNode({loc: [1, 1]}),
|
||||
n2 = iD.osmNode({loc: [3, 3]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(n1).replace(n2);
|
||||
@@ -86,11 +86,11 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('includes intersecting relations after incomplete members are loaded', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
n1 = iD.Node({id: 'n1', loc: [0, 0]}),
|
||||
n2 = iD.Node({id: 'n2', loc: [1, 1]}),
|
||||
relation = iD.Relation({id: 'r', members: [{id: 'n1'}, {id: 'n2'}]}),
|
||||
n1 = iD.osmNode({id: 'n1', loc: [0, 0]}),
|
||||
n2 = iD.osmNode({id: 'n2', loc: [1, 1]}),
|
||||
relation = iD.osmRelation({id: 'r', members: [{id: 'n1'}, {id: 'n2'}]}),
|
||||
extent = iD.geoExtent([0.5, 0.5], [1.5, 1.5]);
|
||||
|
||||
graph.rebase([relation, n1], [graph]);
|
||||
@@ -104,10 +104,10 @@ describe('iD.Tree', function() {
|
||||
|
||||
// This happens when local storage includes a changed way but not its nodes.
|
||||
it('includes intersecting ways after missing nodes are loaded', function() {
|
||||
var base = iD.Graph(),
|
||||
var base = iD.coreGraph(),
|
||||
tree = iD.Tree(base),
|
||||
node = iD.Node({id: 'n', loc: [0.5, 0.5]}),
|
||||
way = iD.Way({nodes: ['n']}),
|
||||
node = iD.osmNode({id: 'n', loc: [0.5, 0.5]}),
|
||||
way = iD.osmWay({nodes: ['n']}),
|
||||
graph = base.replace(way),
|
||||
extent = iD.geoExtent([0, 0], [1, 1]);
|
||||
|
||||
@@ -119,10 +119,10 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('adjusts parent ways when a member node is moved', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
way = iD.Way({nodes: ['n']}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
way = iD.osmWay({nodes: ['n']}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(node).replace(way);
|
||||
@@ -133,10 +133,10 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('adjusts parent relations when a member node is moved', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
relation = iD.Relation({members: [{type: 'node', id: 'n'}]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
relation = iD.osmRelation({members: [{type: 'node', id: 'n'}]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(node).replace(relation);
|
||||
@@ -147,11 +147,11 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('adjusts parent relations of parent ways when a member node is moved', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
way = iD.Way({id: 'w', nodes: ['n']}),
|
||||
relation = iD.Relation({members: [{type: 'multipolygon', id: 'w'}]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
way = iD.osmWay({id: 'w', nodes: ['n']}),
|
||||
relation = iD.osmRelation({members: [{type: 'multipolygon', id: 'w'}]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(node).replace(way).replace(relation);
|
||||
@@ -162,11 +162,11 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('adjusts parent ways when a member node is removed', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
n1 = iD.Node({id: 'n1', loc: [1, 1]}),
|
||||
n2 = iD.Node({id: 'n2', loc: [3, 3]}),
|
||||
way = iD.Way({nodes: ['n1', 'n2']}),
|
||||
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
|
||||
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
|
||||
way = iD.osmWay({nodes: ['n1', 'n2']}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(n1).replace(n2).replace(way);
|
||||
@@ -178,11 +178,11 @@ describe('iD.Tree', function() {
|
||||
|
||||
it('don\'t include parent way multiple times when multiple child nodes are moved', function() {
|
||||
// checks against the following regression: https://github.com/openstreetmap/iD/issues/1978
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
n1 = iD.Node({id: 'n1', loc: [1, 1]}),
|
||||
n2 = iD.Node({id: 'n2', loc: [3, 3]}),
|
||||
way = iD.Way({id: 'w1', nodes: ['n1', 'n2']}),
|
||||
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
|
||||
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
|
||||
way = iD.osmWay({id: 'w1', nodes: ['n1', 'n2']}),
|
||||
extent = iD.geoExtent([0, 0], [4, 4]);
|
||||
|
||||
graph = graph.replace(n1).replace(n2).replace(way);
|
||||
@@ -194,9 +194,9 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('doesn\'t include removed entities', function() {
|
||||
var graph = iD.Graph(),
|
||||
var graph = iD.coreGraph(),
|
||||
tree = iD.Tree(graph),
|
||||
node = iD.Node({loc: [1, 1]}),
|
||||
node = iD.osmNode({loc: [1, 1]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
graph = graph.replace(node);
|
||||
@@ -207,9 +207,9 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('doesn\'t include removed entities after rebase', function() {
|
||||
var base = iD.Graph(),
|
||||
var base = iD.coreGraph(),
|
||||
tree = iD.Tree(base),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
var graph = base.replace(node).remove(node);
|
||||
@@ -221,11 +221,11 @@ describe('iD.Tree', function() {
|
||||
});
|
||||
|
||||
it('handles recursive relations', function() {
|
||||
var base = iD.Graph(),
|
||||
var base = iD.coreGraph(),
|
||||
tree = iD.Tree(base),
|
||||
node = iD.Node({id: 'n', loc: [1, 1]}),
|
||||
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
node = iD.osmNode({id: 'n', loc: [1, 1]}),
|
||||
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
|
||||
r2 = iD.osmRelation({id: 'r2', members: [{id: 'r1'}]}),
|
||||
extent = iD.geoExtent([0, 0], [2, 2]);
|
||||
|
||||
var graph = base.replace(r1).replace(r2);
|
||||
|
||||
Reference in New Issue
Block a user