Add tests for #4589

This commit is contained in:
Bryan Housel
2018-01-09 23:57:44 -05:00
parent 748abdb950
commit 07262fa711
3 changed files with 203 additions and 49 deletions
+62
View File
@@ -394,6 +394,68 @@ describe('iD.actionSplit', function () {
var ids = graph.entity('r').members.map(function(m) { return m.id; });
expect(ids).to.have.ordered.members(['~', '=', '-']);
});
it('adds the new way to parent relations (unsplit way belongs multiple times)', function () {
// Situation:
// a ---- b ---- c ~~~~ d
// Relation: [~~~~, ----, ~~~~]
//
// Split at b.
//
// Expected result:
// a ---- b ==== c ~~~~ d
// Relation: [~~~~, ====, ----, ====, ~~~~]
//
var graph = iD.coreGraph([
iD.osmNode({id: 'a'}),
iD.osmNode({id: 'b'}),
iD.osmNode({id: 'c'}),
iD.osmNode({id: 'd'}),
iD.osmWay({id: '-', nodes: ['a', 'b', 'c']}),
iD.osmWay({id: '~', nodes: ['c', 'd']}),
iD.osmRelation({id: 'r', members: [
{id: '~', type: 'way'},
{id: '-', type: 'way'},
{id: '~', type: 'way'}
]})
]);
graph = iD.actionSplit('b', ['='])(graph);
var ids = graph.entity('r').members.map(function(m) { return m.id; });
expect(ids).to.have.ordered.members(['~', '=', '-', '=', '~']);
});
it('adds the new way to parent relations (split way belongs multiple times)', function () {
// Situation:
// a ---- b ---- c ~~~~ d
// Relation: [----, ~~~~, ----]
//
// Split at b.
//
// Expected result:
// a ---- b ==== c ~~~~ d
// Relation: [----, ====, ~~~~, ====, ----]
//
var graph = iD.coreGraph([
iD.osmNode({id: 'a'}),
iD.osmNode({id: 'b'}),
iD.osmNode({id: 'c'}),
iD.osmNode({id: 'd'}),
iD.osmWay({id: '-', nodes: ['a', 'b', 'c']}),
iD.osmWay({id: '~', nodes: ['c', 'd']}),
iD.osmRelation({id: 'r', members: [
{id: '-', type: 'way'},
{id: '~', type: 'way'},
{id: '-', type: 'way'}
]})
]);
graph = iD.actionSplit('b', ['='])(graph);
var ids = graph.entity('r').members.map(function(m) { return m.id; });
expect(ids).to.have.ordered.members(['-', '=', '~', '=', '-']);
});
});