Merge branch 'develop' into vegbilder

This commit is contained in:
Martin Raifer
2023-07-20 17:21:45 +02:00
307 changed files with 67709 additions and 3411 deletions
+84
View File
@@ -6,4 +6,88 @@ describe('iD.coreLocalizer', function() {
expect(selection.selectChild().classed('localized-text')).to.be.true;
});
});
describe('#floatFormatter', function () {
it('uses the specified number of fraction digits', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('en');
expect(formatFloat(-0.1)).to.eql('-0.1');
expect(formatFloat(-0.1, 0)).to.eql('-0');
expect(formatFloat(-0.1, 2)).to.eql('-0.10');
expect(formatFloat(0.0, 1)).to.eql('0.0');
});
it('roundtrips English numbers', function () {
var localizer = iD.coreLocalizer();
var parseFloat = localizer.floatParser('en');
var formatFloat = localizer.floatFormatter('en');
expect(formatFloat(parseFloat('0.1'))).to.eql('0.1');
expect(formatFloat(parseFloat('.1'))).to.eql('0.1');
expect(formatFloat(parseFloat('-0.1'))).to.eql('-0.1');
expect(formatFloat(parseFloat('1.234'))).to.eql('1.234');
expect(formatFloat(parseFloat('1234'))).to.eql('1,234');
expect(formatFloat(parseFloat('1234.56'))).to.eql('1,234.56');
expect(formatFloat(parseFloat('3.14159'))).to.eql('3.14159');
});
});
describe('#floatParser', function () {
it('roundtrips English numbers', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('en');
var parseFloat = localizer.floatParser('en');
expect(parseFloat(formatFloat(-0.1))).to.eql(-0.1);
expect(parseFloat(formatFloat(1.234))).to.eql(1.234);
expect(parseFloat(formatFloat(1234))).to.eql(1234);
expect(parseFloat(formatFloat(1234.56))).to.eql(1234.56);
expect(parseFloat(formatFloat(3.14159))).to.eql(3.14159);
});
it('roundtrips Spanish numbers', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('es');
var parseFloat = localizer.floatParser('es');
expect(parseFloat(formatFloat(-0.1))).to.eql(-0.1);
expect(parseFloat(formatFloat(1.234))).to.eql(1.234);
expect(parseFloat(formatFloat(1234))).to.eql(1234);
expect(parseFloat(formatFloat(1234.56))).to.eql(1234.56);
expect(parseFloat(formatFloat(3.14159))).to.eql(3.14159);
});
it('roundtrips Hebrew numbers', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('he');
var parseFloat = localizer.floatParser('he');
expect(parseFloat(formatFloat(-0.1))).to.eql(-0.1);
expect(parseFloat(formatFloat(1.234))).to.eql(1.234);
expect(parseFloat(formatFloat(1234))).to.eql(1234);
expect(parseFloat(formatFloat(1234.56))).to.eql(1234.56);
expect(parseFloat(formatFloat(3.14159))).to.eql(3.14159);
});
it('roundtrips Arabic numbers', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('ar-EG');
var parseFloat = localizer.floatParser('ar-EG');
expect(parseFloat(formatFloat(-0.1))).to.eql(-0.1);
expect(parseFloat(formatFloat(1.234))).to.eql(1.234);
expect(parseFloat(formatFloat(1234))).to.eql(1234);
expect(parseFloat(formatFloat(1234.56))).to.eql(1234.56);
expect(parseFloat(formatFloat(3.14159))).to.eql(3.14159);
});
it('roundtrips Bengali numbers', function () {
var localizer = iD.coreLocalizer();
var formatFloat = localizer.floatFormatter('bn');
var parseFloat = localizer.floatParser('bn');
expect(parseFloat(formatFloat(-0.1))).to.eql(-0.1);
expect(parseFloat(formatFloat(1.234))).to.eql(1.234);
expect(parseFloat(formatFloat(1234))).to.eql(1234);
expect(parseFloat(formatFloat(1234.56))).to.eql(1234.56);
expect(parseFloat(formatFloat(3.14159))).to.eql(3.14159);
});
});
describe('#decimalPlaceCounter', function () {
it('counts decimal places in English numbers', function () {
var localizer = iD.coreLocalizer();
var countDecimalPlaces = localizer.decimalPlaceCounter('en');
expect(countDecimalPlaces('-0')).to.eql(0);
expect(countDecimalPlaces('-0.1')).to.eql(1);
expect(countDecimalPlaces('1.234')).to.eql(3);
expect(countDecimalPlaces('10')).to.eql(0);
});
});
});
+3
View File
@@ -359,6 +359,7 @@ describe('iD.osmWay', function() {
expect(iD.osmWay({tags: { barrier: 'guard_rail' }}).sidednessIdentifier()).to.eql('barrier');
expect(iD.osmWay({tags: { barrier: 'city_wall' }}).sidednessIdentifier()).to.eql('barrier');
expect(iD.osmWay({tags: { man_made: 'embankment' }}).sidednessIdentifier()).to.eql('man_made');
expect(iD.osmWay({tags: { 'abandoned:barrier': 'guard_rail' }}).sidednessIdentifier()).to.eql('barrier');
});
it('returns null when tag does not have implied sidedness', function() {
@@ -366,6 +367,8 @@ describe('iD.osmWay', function() {
expect(iD.osmWay({tags: { barrier: 'fence' }}).sidednessIdentifier()).to.be.null;
expect(iD.osmWay({tags: { man_made: 'dyke' }}).sidednessIdentifier()).to.be.null;
expect(iD.osmWay({tags: { highway: 'motorway' }}).sidednessIdentifier()).to.be.null;
expect(iD.osmWay({tags: { 'demolished:highway': 'motorway' }}).sidednessIdentifier()).to.be.null;
expect(iD.osmWay({tags: { 'not:natural': 'cliff' }}).sidednessIdentifier()).to.be.null;
});
});
+1
View File
@@ -53,6 +53,7 @@ describe('iD.presetField', function() {
var context = iD.coreContext().assetPath('../dist/').init();
var uiField = iD.uiFieldCombo(field, context);
uiField(d3.select(document.createElement('div')).classed('form-field-input-wrap', true));
uiField.tags({k: 'v'});
expect(field.t.append).not.to.have.been.called;
expect(other.t.append).to.have.been.called;
+1 -1
View File
@@ -420,7 +420,7 @@ describe('iD.presetIndex', function () {
var graph = iD.coreGraph([surfShop]);
var url = 'https://fakemaprules.io/fake.json';
// no exernal presets yet
// no external presets yet
expect(iD.presetIndex().match(surfShop, graph).id).to.eql('point');
// reset graph...
+6
View File
@@ -75,6 +75,9 @@ describe('iD.serviceNominatim', function() {
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
{zoom: '13', format: 'json', addressdetails: '1', lat: '49', lon: '17'}
);
expect(fetchMock.calls()[0][1].headers).to.eql({
'Accept-Language': 'en'
});
expect(callback).to.have.been.calledWithExactly(null, {address: {country_code:'cz'}});
done();
}, 50);
@@ -144,6 +147,9 @@ describe('iD.serviceNominatim', function() {
window.setTimeout(function() {
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql({format: 'json', limit: '10'});
expect(fetchMock.calls()[0][1].headers).to.eql({
'Accept-Language': 'en'
});
expect(callback).to.have.been.calledOnce;
done();
}, 50);
+17 -1
View File
@@ -2,7 +2,12 @@ describe('iD.validations.crossing_ways', function () {
var context;
beforeEach(function() {
context = iD.coreContext().assetPath('../dist/').init();
const container = d3.select('body').append('div');
context = iD.coreContext().assetPath('../dist/').init().container(container);
container
.append('div')
.attr('class', 'main-map')
.call(context.map());
});
function createWaysWithOneCrossingPoint(tags1, tags2) {
@@ -253,6 +258,17 @@ describe('iD.validations.crossing_ways', function () {
verifySingleCrossingIssue(validate(), {});
});
it('flags sidewalk crossing service road', function() {
createWaysWithOneCrossingPoint({ highway: 'service' }, { highway: 'footway', footway: 'sidewalk' });
const issues = validate();
verifySingleCrossingIssue(issues, {});
context.enter(iD.modeSelect(context, ['w-1']));
const dynamicFixes = issues[0].dynamicFixes(context);
expect(dynamicFixes).to.have.lengthOf(5);
expect(dynamicFixes[0]._connectionTags).to.eql({});
expect(dynamicFixes[1]._connectionTags).to.eql({ highway: 'crossing' });
});
it('flags road crossing railway', function() {
createWaysWithOneCrossingPoint({ highway: 'residential' }, { railway: 'rail' });
verifySingleCrossingIssue(validate(), { railway: 'level_crossing' });