From f1d67e70e0cc00288b4280e6260fc3aeaa6531e6 Mon Sep 17 00:00:00 2001 From: burrscurr Date: Wed, 5 Feb 2025 11:07:55 +0100 Subject: [PATCH] improve test coverage for reversing of turn lane values --- test/spec/actions/reverse.js | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/spec/actions/reverse.js b/test/spec/actions/reverse.js index 58d70c993..7507a8f11 100644 --- a/test/spec/actions/reverse.js +++ b/test/spec/actions/reverse.js @@ -15,6 +15,7 @@ describe('iD.actionReverse', function () { expect(graph.entity(way.id).tags).to.eql({'highway': 'residential'}); }); + describe('reverses directional tags on nodes', function () { it('reverses relative directions', function () { var node1 = iD.osmNode({ tags: { 'direction': 'forward' } }); @@ -95,6 +96,7 @@ describe('iD.actionReverse', function () { }); }); + describe('reverses oneway', function () { it('preserves oneway tags', function () { var way = iD.osmWay({tags: {'oneway': 'yes'}}); @@ -588,6 +590,47 @@ describe('iD.actionReverse', function () { var target = graph.entity(node2.id); expect(target.tags['traffic_signals:direction']).to.eql('empty'); }); + }); + + + describe('does not reverse values which are relative to another reversed tag', function () { + it('preserves the turn direction of a single lane road', function () { + var way = iD.osmWay({tags: {'turn:lanes': 'right'}}); + var graph = iD.actionReverse(way.id)(iD.coreGraph([way])); + var target = graph.entity(way.id); + expect(target.tags['turn:lanes']).to.eql('right'); + }); + + it('preserves the turn directions of a multi-lane road', function () { + var way = iD.osmWay({tags: {'turn:lanes': 'through|through|right'}}); + var graph = iD.actionReverse(way.id)(iD.coreGraph([way])); + var target = graph.entity(way.id); + expect(target.tags['turn:lanes']).to.eql('through|through|right'); + }); + + // https://github.com/openstreetmap/iD/issues/5674 + it('preserves the turn direction of each direction with a single lane', function () { + var way = iD.osmWay({tags: {'turn:lanes:forward': 'right', 'turn:lanes:backward': 'left'}}); + var graph = iD.actionReverse(way.id)(iD.coreGraph([way])); + var target = graph.entity(way.id); + expect(target.tags['turn:lanes:backward']).to.eql('right'); + expect(target.tags['turn:lanes:forward']).to.eql('left'); + }); + + it('preserves the turn direction of each direction with multiple lanes', function () { + var way = iD.osmWay({tags: {'turn:lanes:forward': 'through|right', 'turn:lanes:backward': 'through|through|left'}}); + var graph = iD.actionReverse(way.id)(iD.coreGraph([way])); + var target = graph.entity(way.id); + expect(target.tags['turn:lanes:backward']).to.eql('through|right'); + expect(target.tags['turn:lanes:forward']).to.eql('through|through|left'); + }); + + it('preserves the turn direction of explicitly bidirectional turn lane values', function () { + var way = iD.osmWay({tags: {'turn:lanes:both_ways': 'left'}}); + var graph = iD.actionReverse(way.id)(iD.coreGraph([way])); + var target = graph.entity(way.id); + expect(target.tags['turn:lanes:both_ways']).to.eql('left'); + }); it('preserves the value of the side tag of a cycling waiting aid', function () { var node1 = iD.osmNode();