Skip to content

Commit

Permalink
Add test for route going round loop in other direction
Browse files Browse the repository at this point in the history
  • Loading branch information
ockendenjo committed Dec 18, 2018
1 parent 8aaa387 commit cec4420
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions test/spec/actions/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ describe('iD.actionSplit', function () {
//
// Relation: ['-', '#', '~', '#', '=']
//
var hat1 = iD.coreGraph([
var hat1a = iD.coreGraph([
a, b, c, d, e,
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '#', nodes: ['b', 'c', 'd']}),
Expand All @@ -628,6 +628,31 @@ describe('iD.actionSplit', function () {
})
]);

//
// Situation:
// ###> c >###
// # #
// a --> b ~~~~~~> d ==> e
//
// Relation: ['-', '~', '#', '~', '=']
//
var hat1b = iD.coreGraph([
a, b, c, d, e,
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '#', nodes: ['b', 'c', 'd']}),
iD.osmWay({id: '~', nodes: ['b', 'd']}),
iD.osmWay({id: '=', nodes: ['d', 'e']}),
iD.osmRelation({
id: 'r', members: [
{id: '-', type: 'way'},
{id: '~', type: 'way'},
{id: '#', type: 'way'},
{id: '~', type: 'way'},
{id: '=', type: 'way'}
]
})
]);

//
// Situation:
// ###< c <###
Expand Down Expand Up @@ -728,7 +753,7 @@ describe('iD.actionSplit', function () {
})
]);

it('splits hat1 route at c', function () {
it('splits hat1a route at c', function () {
//
// Expected result:
// ###> c >***
Expand All @@ -737,14 +762,31 @@ describe('iD.actionSplit', function () {
//
// Relation: ['-', '#', '*', '~', '#', '*', '=']
//
var graph = hat1;
var graph = hat1a;
graph = iD.actionSplit('c', ['*'])(graph);

expect(graph.entity('#').nodes).to.eql(['b', 'c']);
expect(graph.entity('*').nodes).to.eql(['c', 'd']);
expect(members(graph)).to.eql(['-', '#', '*', '~', '#', '*', '=']);
});

it('splits hat1b route at c', function () {
//
// Expected result:
// ###> c >***
// # *
// a --> b ~~~~~~> d ==> e
//
// Relation: ['-', '~', '*', '#', '~', '=']
//
var graph = hat1b;
graph = iD.actionSplit('c', ['*'])(graph);

expect(graph.entity('#').nodes).to.eql(['b', 'c']);
expect(graph.entity('*').nodes).to.eql(['c', 'd']);
expect(members(graph)).to.eql(['-', '~', '*', '#', '~', '=']);
});

it('splits hat2 route at c', function () {
//
// Expected result:
Expand Down

0 comments on commit cec4420

Please sign in to comment.