fix another regression (in b72f3aa), add tests

This commit is contained in:
Martin Raifer
2022-11-24 19:11:40 +01:00
parent b72f3aae19
commit fc75d5f2a1
2 changed files with 13 additions and 1 deletions

View File

@@ -111,7 +111,7 @@ export function actionReverse(entityID, options) {
}
return degrees.toString();
} else {
return value;
return valueReplacements[value] || value;
}
}).join(';');
}

View File

@@ -70,6 +70,18 @@ describe('iD.actionReverse', function () {
expect(graph.entity(node1.id).tags).to.eql({ 'direction': '94.5' });
});
it('reverses directions with multiple semicolon separated values', function () {
var node1 = iD.osmNode({ tags: { 'direction': 'N;90' } });
var graph = iD.actionReverse(node1.id)(iD.coreGraph([node1]));
expect(graph.entity(node1.id).tags).to.eql({ 'direction': 'S;270' });
});
it('reverses directions with multiple semicolon separated values, preserves non-directional part', function () {
var node1 = iD.osmNode({ tags: { 'direction': '0;error' } });
var graph = iD.actionReverse(node1.id)(iD.coreGraph([node1]));
expect(graph.entity(node1.id).tags).to.eql({ 'direction': '180;error' });
});
it('preserves non-directional tags', function () {
var node1 = iD.osmNode({ tags: { 'traffic_sign': 'maxspeed' } });
var graph = iD.actionReverse(node1.id)(iD.coreGraph([node1]));