mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
removed formatting
This commit is contained in:
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -29,12 +29,12 @@ function abortRequest(controller) {
|
||||
|
||||
|
||||
function maxPageAtZoom(z) {
|
||||
if (z < 15) return 2;
|
||||
if (z < 15) return 2;
|
||||
if (z === 15) return 5;
|
||||
if (z === 16) return 10;
|
||||
if (z === 17) return 20;
|
||||
if (z === 18) return 40;
|
||||
if (z > 18) return 80;
|
||||
if (z > 18) return 80;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,15 @@ function loadTiles(which, url, projection) {
|
||||
|
||||
// abort inflight requests that are no longer needed
|
||||
var cache = _oscCache[which];
|
||||
Object.keys(cache.inflight).forEach(function (k) {
|
||||
var wanted = tiles.find(function (tile) { return k.indexOf(tile.id + ',') === 0; });
|
||||
Object.keys(cache.inflight).forEach(function(k) {
|
||||
var wanted = tiles.find(function(tile) { return k.indexOf(tile.id + ',') === 0; });
|
||||
if (!wanted) {
|
||||
abortRequest(cache.inflight[k]);
|
||||
delete cache.inflight[k];
|
||||
}
|
||||
});
|
||||
|
||||
tiles.forEach(function (tile) {
|
||||
tiles.forEach(function(tile) {
|
||||
loadNextTilePage(which, currZoom, url, tile);
|
||||
});
|
||||
}
|
||||
@@ -87,14 +87,14 @@ function loadNextTilePage(which, currZoom, url, tile) {
|
||||
};
|
||||
|
||||
d3_json(url, options)
|
||||
.then(function (data) {
|
||||
.then(function(data) {
|
||||
cache.loaded[id] = true;
|
||||
delete cache.inflight[id];
|
||||
if (!data || !data.currentPageItems || !data.currentPageItems.length) {
|
||||
throw new Error('No Data');
|
||||
}
|
||||
|
||||
var features = data.currentPageItems.map(function (item) {
|
||||
var features = data.currentPageItems.map(function(item) {
|
||||
var loc = [+item.lng, +item.lat];
|
||||
var d;
|
||||
|
||||
@@ -138,7 +138,7 @@ function loadNextTilePage(which, currZoom, url, tile) {
|
||||
dispatch.call('loadedImages');
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
.catch(function() {
|
||||
cache.loaded[id] = true;
|
||||
delete cache.inflight[id];
|
||||
});
|
||||
@@ -152,7 +152,7 @@ function partitionViewport(projection) {
|
||||
var tiler = utilTiler().zoomExtent([z2, z2]);
|
||||
|
||||
return tiler.getTiles(projection)
|
||||
.map(function (tile) { return tile.extent; });
|
||||
.map(function(tile) { return tile.extent; });
|
||||
}
|
||||
|
||||
|
||||
@@ -161,10 +161,10 @@ function searchLimited(limit, projection, rtree) {
|
||||
limit = limit || 5;
|
||||
|
||||
return partitionViewport(projection)
|
||||
.reduce(function (result, extent) {
|
||||
.reduce(function(result, extent) {
|
||||
var found = rtree.search(extent.bbox())
|
||||
.slice(0, limit)
|
||||
.map(function (d) { return d.data; });
|
||||
.map(function(d) { return d.data; });
|
||||
|
||||
return (found.length ? result.concat(found) : result);
|
||||
}, []);
|
||||
@@ -173,7 +173,7 @@ function searchLimited(limit, projection, rtree) {
|
||||
|
||||
export default {
|
||||
|
||||
init: function () {
|
||||
init: function() {
|
||||
if (!_oscCache) {
|
||||
this.reset();
|
||||
}
|
||||
@@ -181,7 +181,7 @@ export default {
|
||||
this.event = utilRebind(this, dispatch, 'on');
|
||||
},
|
||||
|
||||
reset: function () {
|
||||
reset: function() {
|
||||
if (_oscCache) {
|
||||
Object.values(_oscCache.images.inflight).forEach(abortRequest);
|
||||
}
|
||||
@@ -195,13 +195,13 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
images: function (projection) {
|
||||
images: function(projection) {
|
||||
var limit = 5;
|
||||
return searchLimited(limit, projection, _oscCache.images.rtree);
|
||||
},
|
||||
|
||||
|
||||
sequences: function (projection) {
|
||||
sequences: function(projection) {
|
||||
var viewport = projection.clipExtent();
|
||||
var min = [viewport[0][0], viewport[1][1]];
|
||||
var max = [viewport[1][0], viewport[0][1]];
|
||||
@@ -210,12 +210,12 @@ export default {
|
||||
|
||||
// all sequences for images in viewport
|
||||
_oscCache.images.rtree.search(bbox)
|
||||
.forEach(function (d) { sequenceKeys[d.data.sequence_id] = true; });
|
||||
.forEach(function(d) { sequenceKeys[d.data.sequence_id] = true; });
|
||||
|
||||
// make linestrings from those sequences
|
||||
var lineStrings = [];
|
||||
Object.keys(sequenceKeys)
|
||||
.forEach(function (sequenceKey) {
|
||||
.forEach(function(sequenceKey) {
|
||||
var seq = _oscCache.sequences[sequenceKey];
|
||||
var images = seq && seq.images;
|
||||
|
||||
@@ -224,8 +224,8 @@ export default {
|
||||
type: 'LineString',
|
||||
coordinates: images.map(function (d) { return d.loc; }).filter(Boolean),
|
||||
properties: {
|
||||
captured_at: images[0] ? images[0].captured_at : null,
|
||||
captured_by: images[0] ? images[0].captured_by : null,
|
||||
captured_at: images[0] ? images[0].captured_at: null,
|
||||
captured_by: images[0] ? images[0].captured_by: null,
|
||||
key: sequenceKey
|
||||
}
|
||||
});
|
||||
@@ -235,18 +235,18 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
cachedImage: function (imageKey) {
|
||||
cachedImage: function(imageKey) {
|
||||
return _oscCache.images.forImageKey[imageKey];
|
||||
},
|
||||
|
||||
|
||||
loadImages: function (projection) {
|
||||
loadImages: function(projection) {
|
||||
var url = apibase + '/1.0/list/nearby-photos/';
|
||||
loadTiles('images', url, projection);
|
||||
},
|
||||
|
||||
|
||||
ensureViewerLoaded: function (context) {
|
||||
ensureViewerLoaded: function(context) {
|
||||
|
||||
if (_loadViewerPromise) return _loadViewerPromise;
|
||||
|
||||
@@ -299,7 +299,7 @@ export default {
|
||||
|
||||
|
||||
// Register viewer resize handler
|
||||
context.ui().photoviewer.on('resize.openstreetcam', function (dimensions) {
|
||||
context.ui().photoviewer.on('resize.openstreetcam', function(dimensions) {
|
||||
imgZoom = d3_zoom()
|
||||
.extent([[0, 0], dimensions])
|
||||
.translateExtent([[0, 0], dimensions])
|
||||
@@ -316,7 +316,7 @@ export default {
|
||||
|
||||
|
||||
function rotate(deg) {
|
||||
return function () {
|
||||
return function() {
|
||||
if (!_oscSelectedImage) return;
|
||||
var sequenceKey = _oscSelectedImage.sequence_id;
|
||||
var sequence = _oscCache.sequences[sequenceKey];
|
||||
@@ -344,7 +344,7 @@ export default {
|
||||
}
|
||||
|
||||
function step(stepBy) {
|
||||
return function () {
|
||||
return function() {
|
||||
if (!_oscSelectedImage) return;
|
||||
var sequenceKey = _oscSelectedImage.sequence_id;
|
||||
var sequence = _oscCache.sequences[sequenceKey];
|
||||
@@ -368,7 +368,7 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
showViewer: function (context) {
|
||||
showViewer: function(context) {
|
||||
var viewer = context.container().select('.photoviewer')
|
||||
.classed('hide', false);
|
||||
|
||||
@@ -388,7 +388,7 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
hideViewer: function (context) {
|
||||
hideViewer: function(context) {
|
||||
_oscSelectedImage = null;
|
||||
|
||||
this.updateUrlImage(null);
|
||||
@@ -408,7 +408,7 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
selectImage: function (context, imageKey) {
|
||||
selectImage: function(context, imageKey) {
|
||||
|
||||
var d = this.cachedImage(imageKey);
|
||||
|
||||
@@ -494,12 +494,12 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
getSelectedImage: function () {
|
||||
getSelectedImage: function() {
|
||||
return _oscSelectedImage;
|
||||
},
|
||||
|
||||
|
||||
getSequenceKeyForImage: function (d) {
|
||||
getSequenceKeyForImage: function(d) {
|
||||
return d && d.sequence_id;
|
||||
},
|
||||
|
||||
@@ -507,7 +507,7 @@ export default {
|
||||
// Updates the currently highlighted sequence and selected bubble.
|
||||
// Reset is only necessary when interacting with the viewport because
|
||||
// this implicitly changes the currently selected bubble/sequence
|
||||
setStyles: function (context, hovered, reset) {
|
||||
setStyles: function(context, hovered, reset) {
|
||||
if (reset) { // reset all layers
|
||||
context.container().selectAll('.viewfield-group')
|
||||
.classed('highlighted', false)
|
||||
@@ -535,13 +535,13 @@ export default {
|
||||
var highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
|
||||
|
||||
context.container().selectAll('.layer-openstreetcam .viewfield-group')
|
||||
.classed('highlighted', function (d) { return highlightedImageKeys.indexOf(d.key) !== -1; })
|
||||
.classed('hovered', function (d) { return d.key === hoveredImageKey; })
|
||||
.classed('currentView', function (d) { return d.key === selectedImageKey; });
|
||||
.classed('highlighted', function(d) { return highlightedImageKeys.indexOf(d.key) !== -1; })
|
||||
.classed('hovered', function(d) { return d.key === hoveredImageKey; })
|
||||
.classed('currentView', function(d) { return d.key === selectedImageKey; });
|
||||
|
||||
context.container().selectAll('.layer-openstreetcam .sequence')
|
||||
.classed('highlighted', function (d) { return d.properties.key === hoveredSequenceKey; })
|
||||
.classed('currentView', function (d) { return d.properties.key === selectedSequenceKey; });
|
||||
.classed('highlighted', function(d) { return d.properties.key === hoveredSequenceKey; })
|
||||
.classed('currentView', function(d) { return d.properties.key === selectedSequenceKey; });
|
||||
|
||||
// update viewfields if needed
|
||||
context.container().selectAll('.layer-openstreetcam .viewfield-group .viewfield')
|
||||
@@ -560,7 +560,7 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
updateUrlImage: function (imageKey) {
|
||||
updateUrlImage: function(imageKey) {
|
||||
if (!window.mocha) {
|
||||
var hash = utilStringQs(window.location.hash);
|
||||
if (imageKey) {
|
||||
@@ -573,7 +573,7 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
cache: function () {
|
||||
cache: function() {
|
||||
return _oscCache;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@ import { actionChangeTags } from '../actions/change_tags';
|
||||
import { actionMergeNodes } from '../actions/merge_nodes';
|
||||
import { actionSplit } from '../actions/split';
|
||||
import { modeSelect } from '../modes/select';
|
||||
import {
|
||||
geoAngle, geoExtent, geoLatToMeters, geoLonToMeters, geoLineIntersection,
|
||||
geoSphericalClosestNode, geoSphericalDistance, geoVecAngle, geoVecLength, geoMetersToLat, geoMetersToLon
|
||||
} from '../geo';
|
||||
import { geoAngle, geoExtent, geoLatToMeters, geoLonToMeters, geoLineIntersection,
|
||||
geoSphericalClosestNode, geoSphericalDistance, geoVecAngle, geoVecLength, geoMetersToLat, geoMetersToLon } from '../geo';
|
||||
import { osmNode } from '../osm/node';
|
||||
import { osmFlowingWaterwayTagValues, osmPathHighwayTagValues, osmRailwayTrackTagValues, osmRoutableHighwayTagValues } from '../osm/tags';
|
||||
import { t } from '../core/localizer';
|
||||
@@ -314,7 +312,7 @@ export function validationCrossingWays(context) {
|
||||
if (entity.type === 'way') {
|
||||
return [entity];
|
||||
} else if (entity.type === 'relation') {
|
||||
return entity.members.reduce(function (array, member) {
|
||||
return entity.members.reduce(function(array, member) {
|
||||
if (member.type === 'way' &&
|
||||
// only look at geometry ways
|
||||
(!member.role || member.role === 'outer' || member.role === 'inner')) {
|
||||
@@ -353,7 +351,7 @@ export function validationCrossingWays(context) {
|
||||
function createIssue(crossing, graph) {
|
||||
|
||||
// use the entities with the tags that define the feature type
|
||||
crossing.wayInfos.sort(function (way1Info, way2Info) {
|
||||
crossing.wayInfos.sort(function(way1Info, way2Info) {
|
||||
var type1 = way1Info.featureType;
|
||||
var type2 = way2Info.featureType;
|
||||
if (type1 === type2) {
|
||||
@@ -365,7 +363,7 @@ export function validationCrossingWays(context) {
|
||||
}
|
||||
return type1 < type2;
|
||||
});
|
||||
var entities = crossing.wayInfos.map(function (wayInfo) {
|
||||
var entities = crossing.wayInfos.map(function(wayInfo) {
|
||||
return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
|
||||
});
|
||||
var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
|
||||
@@ -378,9 +376,9 @@ export function validationCrossingWays(context) {
|
||||
|
||||
var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
|
||||
var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, 'tunnel') &&
|
||||
allowsTunnel(featureType2) && hasTag(entities[1].tags, 'tunnel');
|
||||
allowsTunnel(featureType2) && hasTag(entities[1].tags, 'tunnel');
|
||||
var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, 'bridge') &&
|
||||
allowsBridge(featureType2) && hasTag(entities[1].tags, 'bridge');
|
||||
allowsBridge(featureType2) && hasTag(entities[1].tags, 'bridge');
|
||||
|
||||
var subtype = [featureType1, featureType2].sort().join('-');
|
||||
|
||||
@@ -404,7 +402,7 @@ export function validationCrossingWays(context) {
|
||||
type: type,
|
||||
subtype: subtype,
|
||||
severity: 'warning',
|
||||
message: function (context) {
|
||||
message: function(context) {
|
||||
var graph = context.graph();
|
||||
var entity1 = graph.hasEntity(this.entityIds[0]),
|
||||
entity2 = graph.hasEntity(this.entityIds[1]);
|
||||
@@ -414,7 +412,7 @@ export function validationCrossingWays(context) {
|
||||
}) : '';
|
||||
},
|
||||
reference: showReference,
|
||||
entityIds: entities.map(function (entity) {
|
||||
entityIds: entities.map(function(entity) {
|
||||
return entity.id;
|
||||
}),
|
||||
data: {
|
||||
@@ -424,7 +422,7 @@ export function validationCrossingWays(context) {
|
||||
},
|
||||
hash: uniqueID,
|
||||
loc: crossing.crossPoint,
|
||||
dynamicFixes: function (context) {
|
||||
dynamicFixes: function(context) {
|
||||
var mode = context.mode();
|
||||
if (!mode || mode.id !== 'select' || mode.selectedIDs().length !== 1) return [];
|
||||
|
||||
@@ -446,12 +444,12 @@ export function validationCrossingWays(context) {
|
||||
} else if (isCrossingTunnels ||
|
||||
isCrossingBridges ||
|
||||
featureType1 === 'building' ||
|
||||
featureType2 === 'building') {
|
||||
featureType2 === 'building') {
|
||||
|
||||
fixes.push(makeChangeLayerFix('higher'));
|
||||
fixes.push(makeChangeLayerFix('lower'));
|
||||
|
||||
// can only add bridge/tunnel if both features are lines
|
||||
// can only add bridge/tunnel if both features are lines
|
||||
} else if (context.graph().geometry(this.entityIds[0]) === 'line' &&
|
||||
context.graph().geometry(this.entityIds[1]) === 'line') {
|
||||
|
||||
@@ -487,11 +485,11 @@ export function validationCrossingWays(context) {
|
||||
}
|
||||
}
|
||||
|
||||
function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
|
||||
function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel){
|
||||
return new validationIssueFix({
|
||||
icon: iconName,
|
||||
title: t.html('issues.fix.' + fixTitleID + '.title'),
|
||||
onClick: function (context) {
|
||||
onClick: function(context) {
|
||||
var mode = context.mode();
|
||||
if (!mode || mode.id !== 'select') return;
|
||||
|
||||
@@ -583,10 +581,10 @@ export function validationCrossingWays(context) {
|
||||
]);
|
||||
}
|
||||
|
||||
var endpointLocGetter1 = function (lengthMeters) {
|
||||
var endpointLocGetter1 = function(lengthMeters) {
|
||||
return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
|
||||
};
|
||||
var endpointLocGetter2 = function (lengthMeters) {
|
||||
var endpointLocGetter2 = function(lengthMeters) {
|
||||
return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
|
||||
};
|
||||
|
||||
@@ -614,8 +612,8 @@ export function validationCrossingWays(context) {
|
||||
|
||||
} else {
|
||||
var edgeCount = 0;
|
||||
endNode.parentIntersectionWays(graph).forEach(function (way) {
|
||||
way.nodes.forEach(function (nodeID) {
|
||||
endNode.parentIntersectionWays(graph).forEach(function(way) {
|
||||
way.nodes.forEach(function(nodeID) {
|
||||
if (nodeID === endNode.id) {
|
||||
if ((endNode.id === way.first() && endNode.id !== way.last()) ||
|
||||
(endNode.id === way.last() && endNode.id !== way.first())) {
|
||||
@@ -659,15 +657,15 @@ export function validationCrossingWays(context) {
|
||||
var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
|
||||
var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
|
||||
|
||||
var structureWay = resultWayIDs.map(function (id) {
|
||||
var structureWay = resultWayIDs.map(function(id) {
|
||||
return graph.entity(id);
|
||||
}).find(function (way) {
|
||||
}).find(function(way) {
|
||||
return way.nodes.indexOf(structEndNode1.id) !== -1 &&
|
||||
way.nodes.indexOf(structEndNode2.id) !== -1;
|
||||
});
|
||||
|
||||
var tags = Object.assign({}, structureWay.tags); // copy tags
|
||||
if (bridgeOrTunnel === 'bridge') {
|
||||
if (bridgeOrTunnel === 'bridge'){
|
||||
tags.bridge = 'yes';
|
||||
tags.layer = '1';
|
||||
} else {
|
||||
@@ -700,7 +698,7 @@ export function validationCrossingWays(context) {
|
||||
return new validationIssueFix({
|
||||
icon: 'iD-icon-crossing',
|
||||
title: t.html('issues.fix.' + fixTitleID + '.title'),
|
||||
onClick: function (context) {
|
||||
onClick: function(context) {
|
||||
var loc = this.issue.loc;
|
||||
var connectionTags = this.issue.data.connectionTags;
|
||||
var edges = this.issue.data.edges;
|
||||
@@ -714,16 +712,16 @@ export function validationCrossingWays(context) {
|
||||
var nodesToMerge = [node.id];
|
||||
var mergeThresholdInMeters = 0.75;
|
||||
|
||||
edges.forEach(function (edge) {
|
||||
edges.forEach(function(edge) {
|
||||
var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
|
||||
var nearby = geoSphericalClosestNode(edgeNodes, loc);
|
||||
// if there is already a suitable node nearby, use that
|
||||
// use the node if node has no interesting tags or if it is a crossing node #8326
|
||||
if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
|
||||
nodesToMerge.push(nearby.node.id);
|
||||
// else add the new node to the way
|
||||
// else add the new node to the way
|
||||
} else {
|
||||
graph = actionAddMidpoint({ loc: loc, edge: edge }, node)(graph);
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge}, node)(graph);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -744,7 +742,7 @@ export function validationCrossingWays(context) {
|
||||
return new validationIssueFix({
|
||||
icon: 'iD-icon-' + (higherOrLower === 'higher' ? 'up' : 'down'),
|
||||
title: t.html('issues.fix.tag_this_as_' + higherOrLower + '.title'),
|
||||
onClick: function (context) {
|
||||
onClick: function(context) {
|
||||
|
||||
var mode = context.mode();
|
||||
if (!mode || mode.id !== 'select') return;
|
||||
@@ -753,7 +751,7 @@ export function validationCrossingWays(context) {
|
||||
if (selectedIDs.length !== 1) return;
|
||||
|
||||
var selectedID = selectedIDs[0];
|
||||
if (!this.issue.entityIds.some(function (entityId) {
|
||||
if (!this.issue.entityIds.some(function(entityId) {
|
||||
return entityId === selectedID;
|
||||
})) return;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe('iD.behaviorSelect', function () {
|
||||
describe('iD.behaviorSelect', function() {
|
||||
var a, b, context, behavior, container;
|
||||
|
||||
function simulateClick(el, o) {
|
||||
@@ -10,12 +10,12 @@ describe('iD.behaviorSelect', function () {
|
||||
happen.mouseup(el, Object.assign({}, click, o));
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
container = d3.select('body').append('div');
|
||||
context = iD.coreContext().assetPath('../dist/').init().container(container);
|
||||
|
||||
a = iD.osmNode({ loc: [0, 0] });
|
||||
b = iD.osmNode({ loc: [0, 0] });
|
||||
a = iD.osmNode({loc: [0, 0]});
|
||||
b = iD.osmNode({loc: [0, 0]});
|
||||
|
||||
context.perform(iD.actionAddEntity(a), iD.actionAddEntity(b));
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('iD.behaviorSelect', function () {
|
||||
context.surface().select('.data-layer.osm').selectAll('circle')
|
||||
.data([a, b])
|
||||
.enter().append('circle')
|
||||
.attr('class', function (d) { return d.id; });
|
||||
.attr('class', function(d) { return d.id; });
|
||||
|
||||
context.enter(iD.modeBrowse(context));
|
||||
|
||||
@@ -37,78 +37,78 @@ describe('iD.behaviorSelect', function () {
|
||||
context.install(behavior);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
context.uninstall(behavior);
|
||||
context.mode().exit();
|
||||
container.remove();
|
||||
});
|
||||
|
||||
it('refuses to enter select mode with no ids', function () {
|
||||
it('refuses to enter select mode with no ids', function() {
|
||||
context.enter(iD.modeSelect(context, []));
|
||||
expect(context.mode().id, 'empty array').to.eql('browse');
|
||||
context.enter(iD.modeSelect(context, undefined));
|
||||
expect(context.mode().id, 'undefined').to.eql('browse');
|
||||
});
|
||||
|
||||
it('refuses to enter select mode with nonexistent ids', function () {
|
||||
it('refuses to enter select mode with nonexistent ids', function() {
|
||||
context.enter(iD.modeSelect(context, ['w-1']));
|
||||
expect(context.mode().id).to.eql('browse');
|
||||
});
|
||||
|
||||
it('click on entity selects the entity', function (done) {
|
||||
it('click on entity selects the entity', function(done) {
|
||||
var el = context.surface().selectAll('.' + a.id).node();
|
||||
simulateClick(el, {});
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.selectedIDs()).to.eql([a.id]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('click on empty space clears the selection', function (done) {
|
||||
it('click on empty space clears the selection', function(done) {
|
||||
context.enter(iD.modeSelect(context, [a.id]));
|
||||
var el = context.surface().node();
|
||||
simulateClick(el, {});
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.mode().id).to.eql('browse');
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('shift-click on unselected entity adds it to the selection', function (done) {
|
||||
it('shift-click on unselected entity adds it to the selection', function(done) {
|
||||
context.enter(iD.modeSelect(context, [a.id]));
|
||||
var el = context.surface().selectAll('.' + b.id).node();
|
||||
simulateClick(el, { shiftKey: true });
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.selectedIDs()).to.eql([a.id, b.id]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('shift-click on selected entity removes it from the selection', function (done) {
|
||||
it('shift-click on selected entity removes it from the selection', function(done) {
|
||||
context.enter(iD.modeSelect(context, [a.id, b.id]));
|
||||
var el = context.surface().selectAll('.' + b.id).node();
|
||||
simulateClick(el, { shiftKey: true });
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.selectedIDs()).to.eql([a.id]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('shift-click on last selected entity clears the selection', function (done) {
|
||||
it('shift-click on last selected entity clears the selection', function(done) {
|
||||
context.enter(iD.modeSelect(context, [a.id]));
|
||||
var el = context.surface().selectAll('.' + a.id).node();
|
||||
simulateClick(el, { shiftKey: true });
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.mode().id).to.eql('browse');
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('shift-click on empty space leaves the selection unchanged', function (done) {
|
||||
it('shift-click on empty space leaves the selection unchanged', function(done) {
|
||||
context.enter(iD.modeSelect(context, [a.id]));
|
||||
var el = context.surface().node();
|
||||
simulateClick(el, { shiftKey: true });
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.selectedIDs()).to.eql([a.id]);
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
@@ -1,127 +1,127 @@
|
||||
describe('iD.coreLocations', function () {
|
||||
describe('iD.coreLocations', function() {
|
||||
var locationManager, loco;
|
||||
|
||||
var colorado = {
|
||||
type: 'Feature',
|
||||
id: 'colorado.geojson',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[-107.9197, 41.0039],
|
||||
[-102.0539, 41.0039],
|
||||
[-102.043, 36.9948],
|
||||
[-109.0425, 37.0003],
|
||||
[-109.048, 40.9984],
|
||||
[-107.9197, 41.0039]
|
||||
]
|
||||
]
|
||||
}
|
||||
type: 'Feature',
|
||||
id: 'colorado.geojson',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[-107.9197, 41.0039],
|
||||
[-102.0539, 41.0039],
|
||||
[-102.043, 36.9948],
|
||||
[-109.0425, 37.0003],
|
||||
[-109.048, 40.9984],
|
||||
[-107.9197, 41.0039]
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
var fc = { type: 'FeatureCollection', features: [colorado] };
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
// make a new one each time, so we aren't accidentally testing the "global" locationManager
|
||||
locationManager = iD.coreLocations();
|
||||
loco = locationManager.loco();
|
||||
});
|
||||
|
||||
|
||||
describe('#mergeCustomGeoJSON', function () {
|
||||
it('merges geojson into lococation-conflation cache', function () {
|
||||
describe('#mergeCustomGeoJSON', function() {
|
||||
it('merges geojson into lococation-conflation cache', function() {
|
||||
locationManager.mergeCustomGeoJSON(fc);
|
||||
expect(loco._cache['colorado.geojson']).to.be.eql(colorado);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#mergeLocationSets', function () {
|
||||
it('returns a promise rejected if not passed an array', function (done) {
|
||||
describe('#mergeLocationSets', function() {
|
||||
it('returns a promise rejected if not passed an array', function(done) {
|
||||
var prom = locationManager.mergeLocationSets({});
|
||||
prom
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
done(new Error('This was supposed to fail, but somehow succeeded.'));
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
expect(/^nothing to do/.test(err)).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
window.setTimeout(function () { }, 20); // async - to let the promise settle in phantomjs
|
||||
window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
|
||||
});
|
||||
|
||||
it('resolves locationSets, assigning locationSetID', function (done) {
|
||||
it('resolves locationSets, assigning locationSetID', function(done) {
|
||||
var data = [
|
||||
{ id: 'world', locationSet: { include: ['001'] } },
|
||||
{ id: 'usa', locationSet: { include: ['usa'] } }
|
||||
{ id: 'usa', locationSet: { include: ['usa'] } }
|
||||
];
|
||||
var prom = locationManager.mergeLocationSets(data);
|
||||
prom
|
||||
.then(function (data) {
|
||||
.then(function(data) {
|
||||
expect(data).to.be.a('array');
|
||||
expect(data[0].locationSetID).to.eql('+[Q2]');
|
||||
expect(data[1].locationSetID).to.eql('+[Q30]');
|
||||
done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
window.setTimeout(function () { }, 20); // async - to let the promise settle in phantomjs
|
||||
window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
|
||||
});
|
||||
|
||||
it('resolves locationSets, falls back to world locationSetID on errror', function (done) {
|
||||
it('resolves locationSets, falls back to world locationSetID on errror', function(done) {
|
||||
var data = [
|
||||
{ id: 'bogus1', locationSet: { foo: 'bar' } },
|
||||
{ id: 'bogus2', locationSet: { include: ['fake.geojson'] } }
|
||||
];
|
||||
var prom = locationManager.mergeLocationSets(data);
|
||||
prom
|
||||
.then(function (data) {
|
||||
.then(function(data) {
|
||||
expect(data).to.be.a('array');
|
||||
expect(data[0].locationSetID).to.eql('+[Q2]');
|
||||
expect(data[1].locationSetID).to.eql('+[Q2]');
|
||||
done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
window.setTimeout(function () { }, 20); // async - to let the promise settle in phantomjs
|
||||
window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#locationSetID', function () {
|
||||
it('calculates a locationSetID for a locationSet', function () {
|
||||
describe('#locationSetID', function() {
|
||||
it('calculates a locationSetID for a locationSet', function() {
|
||||
expect(locationManager.locationSetID({ include: ['usa'] })).to.be.eql('+[Q30]');
|
||||
});
|
||||
|
||||
it('falls back to the world locationSetID in case of errors', function () {
|
||||
it('falls back to the world locationSetID in case of errors', function() {
|
||||
expect(locationManager.locationSetID({ foo: 'bar' })).to.be.eql('+[Q2]');
|
||||
expect(locationManager.locationSetID({ include: ['fake.geojson'] })).to.be.eql('+[Q2]');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#feature', function () {
|
||||
it('has the world locationSet pre-resolved', function () {
|
||||
describe('#feature', function() {
|
||||
it('has the world locationSet pre-resolved', function() {
|
||||
var result = locationManager.feature('+[Q2]');
|
||||
expect(result).to.include({ type: 'Feature', id: '+[Q2]' });
|
||||
});
|
||||
|
||||
it('falls back to the world locationSetID in case of errors', function () {
|
||||
it('falls back to the world locationSetID in case of errors', function() {
|
||||
var result = locationManager.feature('fake');
|
||||
expect(result).to.include({ type: 'Feature', id: '+[Q2]' });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#locationsAt', function () {
|
||||
it('has the world locationSet pre-resolved', function () {
|
||||
describe('#locationsAt', function() {
|
||||
it('has the world locationSet pre-resolved', function() {
|
||||
var result1 = locationManager.locationsAt([-108.557, 39.065]); // Grand Junction
|
||||
expect(result1).to.be.an('object').that.has.all.keys('+[Q2]');
|
||||
var result2 = locationManager.locationsAt([-74.481, 40.797]); // Morristown
|
||||
@@ -130,7 +130,7 @@ describe('iD.coreLocations', function () {
|
||||
expect(result3).to.be.an('object').that.has.all.keys('+[Q2]');
|
||||
});
|
||||
|
||||
it('returns valid locations at a given lon,lat', function (done) {
|
||||
it('returns valid locations at a given lon,lat', function(done) {
|
||||
// setup, load colorado.geojson and resolve some locationSets
|
||||
locationManager.mergeCustomGeoJSON(fc);
|
||||
locationManager.mergeLocationSets([
|
||||
@@ -138,7 +138,7 @@ describe('iD.coreLocations', function () {
|
||||
{ id: 'OSM-USA', locationSet: { include: ['us'] } },
|
||||
{ id: 'OSM-Colorado', locationSet: { include: ['colorado.geojson'] } }
|
||||
])
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
var result1 = locationManager.locationsAt([-108.557, 39.065]); // Grand Junction
|
||||
expect(result1).to.be.an('object').that.has.all.keys('+[Q2]', '+[Q30]', '+[colorado.geojson]');
|
||||
var result2 = locationManager.locationsAt([-74.481, 40.797]); // Morristown
|
||||
@@ -147,11 +147,11 @@ describe('iD.coreLocations', function () {
|
||||
expect(result3).to.be.an('object').that.has.all.keys('+[Q2]');
|
||||
done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
window.setTimeout(function () { }, 20); // async - to let the promise settle in phantomjs
|
||||
window.setTimeout(function() {}, 20); // async - to let the promise settle in phantomjs
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
describe('iD.serviceMapillary', function () {
|
||||
describe('iD.serviceMapillary', function() {
|
||||
var dimensions = [64, 64];
|
||||
var context, mapillary;
|
||||
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.mapillary = iD.serviceMapillary;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.mapillary;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
context = iD.coreContext().assetPath('../dist/').init();
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(14))
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
mapillary = iD.services.mapillary;
|
||||
mapillary.reset();
|
||||
});
|
||||
|
||||
afterEach(function () { });
|
||||
afterEach(function() {});
|
||||
|
||||
|
||||
describe('#init', function () {
|
||||
it('Initializes cache one time', function () {
|
||||
describe('#init', function() {
|
||||
it('Initializes cache one time', function() {
|
||||
var cache = mapillary.cache();
|
||||
expect(cache).to.have.property('images');
|
||||
expect(cache).to.have.property('image_detections');
|
||||
@@ -41,10 +41,10 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#reset', function () {
|
||||
it('resets cache and image', function () {
|
||||
describe('#reset', function() {
|
||||
it('resets cache and image', function() {
|
||||
mapillary.cache().foo = 'bar';
|
||||
mapillary.selectImage(context, { key: 'baz', loc: [10, 0] });
|
||||
mapillary.selectImage(context, { key: 'baz', loc: [10,0] });
|
||||
|
||||
mapillary.reset();
|
||||
expect(mapillary.cache()).to.not.have.property('foo');
|
||||
@@ -53,31 +53,31 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#images', function () {
|
||||
it('returns images in the visible map area', function () {
|
||||
describe('#images', function() {
|
||||
it('returns images in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1], ca: 90 } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], ca: 90 } }
|
||||
];
|
||||
|
||||
mapillary.cache().images.rtree.load(features);
|
||||
var res = mapillary.images(context.projection);
|
||||
|
||||
expect(res).to.deep.eql([
|
||||
{ key: '0', loc: [10, 0], ca: 90 },
|
||||
{ key: '1', loc: [10, 0], ca: 90 }
|
||||
{ key: '0', loc: [10,0], ca: 90 },
|
||||
{ key: '1', loc: [10,0], ca: 90 }
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits results no more than 5 stacked images in one spot', function () {
|
||||
it('limits results no more than 5 stacked images in one spot', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10, 0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10, 0], ca: 90 } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0], ca: 90 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10,0], ca: 90 } }
|
||||
];
|
||||
|
||||
mapillary.cache().images.rtree.load(features);
|
||||
@@ -87,31 +87,31 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#signs', function () {
|
||||
it('returns signs in the visible map area', function () {
|
||||
describe('#signs', function() {
|
||||
it('returns signs in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1] } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1] } }
|
||||
];
|
||||
|
||||
mapillary.cache().signs.rtree.load(features);
|
||||
var res = mapillary.signs(context.projection);
|
||||
|
||||
expect(res).to.deep.eql([
|
||||
{ key: '0', loc: [10, 0] },
|
||||
{ key: '1', loc: [10, 0] }
|
||||
{ key: '0', loc: [10,0] },
|
||||
{ key: '1', loc: [10,0] }
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits results no more than 5 stacked signs in one spot', function () {
|
||||
it('limits results no more than 5 stacked signs in one spot', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10, 0] } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10,0] } }
|
||||
];
|
||||
|
||||
mapillary.cache().signs.rtree.load(features);
|
||||
@@ -121,35 +121,35 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#mapFeatures', function () {
|
||||
it('returns map features in the visible map area', function () {
|
||||
describe('#mapFeatures', function() {
|
||||
it('returns map features in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1] } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1] } }
|
||||
];
|
||||
|
||||
mapillary.cache().points.rtree.load(features);
|
||||
var res = mapillary.mapFeatures(context.projection);
|
||||
|
||||
expect(res).to.deep.eql([
|
||||
{ key: '0', loc: [10, 0] },
|
||||
{ key: '1', loc: [10, 0] }
|
||||
{ key: '0', loc: [10,0] },
|
||||
{ key: '1', loc: [10,0] }
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits results no more than 5 stacked map features in one spot', function () {
|
||||
it('limits results no more than 5 stacked map features in one spot', function() {
|
||||
var detections = [{
|
||||
detection_key: '78vqha63gs1upg15s823qckcmn',
|
||||
image_key: 'bwYs-uXLDvm_meo_EC5Nzw'
|
||||
}];
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10, 0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10, 0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10, 0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10, 0], detections: detections } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10,0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10,0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0], detections: detections } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10,0], detections: detections } }
|
||||
];
|
||||
|
||||
mapillary.cache().points.rtree.load(features);
|
||||
@@ -159,12 +159,12 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#sequences', function () {
|
||||
it('returns sequence linestrings in the visible map area', function () {
|
||||
describe('#sequences', function() {
|
||||
it('returns sequence linestrings in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90, sequence_id: '-' } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90, sequence_id: '-' } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1], ca: 90, sequence_id: '-' } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90, sequence_id: '-' } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90, sequence_id: '-' } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], ca: 90, sequence_id: '-' } }
|
||||
];
|
||||
|
||||
mapillary.cache().images.rtree.load(features);
|
||||
@@ -173,7 +173,7 @@ describe('iD.serviceMapillary', function () {
|
||||
type: 'Feature',
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
coordinates: [[10, 0], [10, 0], [10, 1]],
|
||||
coordinates: [[10,0], [10,0], [10,1]],
|
||||
properties: {
|
||||
key: '-',
|
||||
pano: false,
|
||||
@@ -193,17 +193,17 @@ describe('iD.serviceMapillary', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#setActiveImage', function () {
|
||||
it('gets and sets the selected image', function () {
|
||||
var node = { id: 'baz', originalLngLat: { lng: 10, lat: 0 } };
|
||||
describe('#setActiveImage', function() {
|
||||
it('gets and sets the selected image', function() {
|
||||
var node = { id: 'baz', originalLngLat: {lng: 10, lat: 0}};
|
||||
mapillary.setActiveImage(node);
|
||||
expect(mapillary.getActiveImage().id).to.eql(node.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#filterViewer', function () {
|
||||
it('filters images by dates', function () {
|
||||
describe('#filterViewer', function() {
|
||||
it('filters images by dates', function() {
|
||||
context.photos().setDateFilter('fromDate', '2020-01-01');
|
||||
context.photos().setDateFilter('toDate', '2021-01-01');
|
||||
var filter = mapillary.filterViewer(context);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('maprules', function () {
|
||||
describe('maprules', function() {
|
||||
var _ruleChecks, _savedAreaKeys, validationRules;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
_savedAreaKeys = iD.osmAreaKeys;
|
||||
iD.osmSetAreaKeys({ building: {}, amenity: {} });
|
||||
|
||||
@@ -10,16 +10,16 @@ describe('maprules', function () {
|
||||
_ruleChecks = iD.serviceMapRules.ruleChecks();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
iD.osmSetAreaKeys(_savedAreaKeys);
|
||||
delete iD.services.maprules;
|
||||
});
|
||||
|
||||
describe('#filterRuleChecks', function () {
|
||||
it('returns shortlist of mapcss checks relevant to provided selector', function () {
|
||||
describe('#filterRuleChecks', function() {
|
||||
it('returns shortlist of mapcss checks relevant to provided selector', function() {
|
||||
var selector = {
|
||||
geometry: 'closedway',
|
||||
equals: { amenity: 'marketplace' },
|
||||
equals: {amenity: 'marketplace'},
|
||||
absence: 'name',
|
||||
error: '\'Marketplace\' preset must be coupled with name'
|
||||
};
|
||||
@@ -34,8 +34,8 @@ describe('maprules', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#buildTagMap', function () {
|
||||
it('builds a map of tag keys/values found in mapcss selector', function () {
|
||||
describe('#buildTagMap', function() {
|
||||
it('builds a map of tag keys/values found in mapcss selector', function() {
|
||||
[
|
||||
{
|
||||
t: {
|
||||
@@ -90,14 +90,14 @@ describe('maprules', function () {
|
||||
lanes: [4, 1]
|
||||
}
|
||||
}
|
||||
].forEach(function (test) {
|
||||
].forEach(function(test) {
|
||||
expect(iD.serviceMapRules.buildTagMap(test.t)).to.eql(test.r);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#inferGeometry', function () {
|
||||
it('infers geometry using selector keys', function () {
|
||||
describe('#inferGeometry', function() {
|
||||
it('infers geometry using selector keys', function() {
|
||||
|
||||
var amenityDerivedArea = {
|
||||
geometry: 'closedway',
|
||||
@@ -148,32 +148,32 @@ describe('maprules', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#addRule', function () {
|
||||
describe('#addRule', function() {
|
||||
it('builds a rule from provided selector and adds it to _validationRules', function () {
|
||||
var selector = {
|
||||
geometry: 'node',
|
||||
equals: { amenity: 'marketplace' },
|
||||
absence: 'name',
|
||||
warning: '\'Marketplace\' preset must be coupled with name'
|
||||
geometry:'node',
|
||||
equals: {amenity:'marketplace'},
|
||||
absence:'name',
|
||||
warning:'\'Marketplace\' preset must be coupled with name'
|
||||
};
|
||||
expect(iD.serviceMapRules.validationRules()).to.be.empty;
|
||||
iD.serviceMapRules.addRule(selector);
|
||||
expect(iD.serviceMapRules.validationRules().length).to.eql(1);
|
||||
});
|
||||
});
|
||||
describe('#clearRules', function () {
|
||||
it('clears _validationRules array', function () {
|
||||
describe('#clearRules', function() {
|
||||
it('clears _validationRules array', function() {
|
||||
expect(iD.serviceMapRules.validationRules().length).to.eql(1);
|
||||
iD.serviceMapRules.clearRules();
|
||||
expect(iD.serviceMapRules.validationRules()).to.be.empty;
|
||||
});
|
||||
});
|
||||
|
||||
describe('#validationRules', function () {
|
||||
it('returns _validationRules array', function () {
|
||||
describe('#validationRules', function() {
|
||||
it('returns _validationRules array', function() {
|
||||
var selector = {
|
||||
geometry: 'closedway',
|
||||
equals: { amenity: 'marketplace' },
|
||||
equals: {amenity: 'marketplace'},
|
||||
absence: 'name',
|
||||
error: '\'Marketplace\' preset must be coupled with name'
|
||||
};
|
||||
@@ -185,71 +185,71 @@ describe('maprules', function () {
|
||||
});
|
||||
|
||||
describe('_ruleChecks', function () {
|
||||
describe('#equals', function () {
|
||||
it('is true when two tag maps intersect', function () {
|
||||
describe('#equals', function() {
|
||||
it('is true when two tag maps intersect', function() {
|
||||
var a = { amenity: 'school' };
|
||||
var b = { amenity: 'school' };
|
||||
expect(_ruleChecks.equals(a)(b)).to.be.true;
|
||||
});
|
||||
it('is false when two tag maps intersect', function () {
|
||||
it('is false when two tag maps intersect', function() {
|
||||
var a = { man_made: 'water_tap' };
|
||||
var b = { amenity: 'school' };
|
||||
expect(_ruleChecks.equals(a)(b)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('#notEquals', function () {
|
||||
it('is true when two tag maps do not intersect', function () {
|
||||
describe('#notEquals', function() {
|
||||
it('is true when two tag maps do not intersect', function() {
|
||||
var a = { man_made: 'water_tap' };
|
||||
var b = { amenity: 'school' };
|
||||
expect(_ruleChecks.notEquals(a)(b)).to.be.true;
|
||||
});
|
||||
it('is not true when two tag maps intersect', function () {
|
||||
it('is not true when two tag maps intersect', function() {
|
||||
var a = { amenity: 'school' };
|
||||
var b = { amenity: 'school', opening_hours: '9-5' };
|
||||
expect(_ruleChecks.notEquals(a)(b)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('absence', function () {
|
||||
it('is true when tag map keys does not include key in question', function () {
|
||||
describe('absence', function() {
|
||||
it('is true when tag map keys does not include key in question', function() {
|
||||
var key = 'amenity';
|
||||
var map = { building: 'yes' };
|
||||
expect(_ruleChecks.absence(key)(map)).to.be.true;
|
||||
});
|
||||
it('is false when tag map keys does include key in question', function () {
|
||||
it('is false when tag map keys does include key in question', function() {
|
||||
var key = 'amenity';
|
||||
var map = { amenity: 'school' };
|
||||
expect(_ruleChecks.absence(key)(map)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('presence', function () {
|
||||
it('is true when tag map keys includes key in question', function () {
|
||||
describe('presence', function() {
|
||||
it('is true when tag map keys includes key in question', function() {
|
||||
var key = 'amenity';
|
||||
var map = { amenity: 'school' };
|
||||
var map = { amenity: 'school'};
|
||||
expect(_ruleChecks.presence(key)(map)).to.be.true;
|
||||
});
|
||||
it('is false when tag map keys do not include key in question', function () {
|
||||
it('is false when tag map keys do not include key in question', function() {
|
||||
var key = 'amenity';
|
||||
var map = { building: 'yes' };
|
||||
var map = { building: 'yes'};
|
||||
expect(_ruleChecks.presence(key)(map)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('greaterThan', function () {
|
||||
it('is true when a tag value is greater than the selector value', function () {
|
||||
describe('greaterThan', function() {
|
||||
it('is true when a tag value is greater than the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
var tags = { lanes: 6 };
|
||||
var tags = { lanes : 6 };
|
||||
expect(_ruleChecks.greaterThan(selectorTags)(tags)).to.be.true;
|
||||
});
|
||||
it('is false when a tag value is less than or equal to the selector value', function () {
|
||||
it('is false when a tag value is less than or equal to the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
[4, 5].forEach(function (val) {
|
||||
[4, 5].forEach(function(val) {
|
||||
expect(_ruleChecks.greaterThan(selectorTags)({ lanes: val })).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('greaterThanEqual', function () {
|
||||
it('is true when a tag value is greater than or equal to the selector value', function () {
|
||||
describe('greaterThanEqual', function() {
|
||||
it('is true when a tag value is greater than or equal to the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
[5, 6].forEach(function (val) {
|
||||
[5, 6].forEach(function(val) {
|
||||
expect(_ruleChecks.greaterThanEqual(selectorTags)({ lanes: val })).to.be.true;
|
||||
});
|
||||
});
|
||||
@@ -259,64 +259,64 @@ describe('maprules', function () {
|
||||
expect(_ruleChecks.greaterThanEqual(selectorTags)(tags)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('lessThan', function () {
|
||||
it('is true when a tag value is less than the selector value', function () {
|
||||
describe('lessThan', function() {
|
||||
it('is true when a tag value is less than the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
var tags = { lanes: 4 };
|
||||
expect(_ruleChecks.lessThan(selectorTags)(tags)).to.be.true;
|
||||
});
|
||||
it('is false when a tag value is greater than or equal to the selector value', function () {
|
||||
it('is false when a tag value is greater than or equal to the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
[6, 7].forEach(function (val) {
|
||||
expect(_ruleChecks.lessThan(selectorTags)({ lanes: val })).to.be.false;
|
||||
});
|
||||
[6, 7].forEach(function(val) {
|
||||
expect(_ruleChecks.lessThan(selectorTags)({ lanes: val })).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('lessThanEqual', function () {
|
||||
it('is true when a tag value is less than or equal to the selector value', function () {
|
||||
describe('lessThanEqual', function() {
|
||||
it('is true when a tag value is less than or equal to the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
[4, 5].forEach(function (val) {
|
||||
[4, 5].forEach(function(val) {
|
||||
expect(_ruleChecks.lessThanEqual(selectorTags)({ lanes: val })).to.be.true;
|
||||
});
|
||||
});
|
||||
it('is false when a tag value is greater than the selector value', function () {
|
||||
var selectorTags = { lanes: 5 };
|
||||
var tags = { lanes: 6 };
|
||||
expect(_ruleChecks.lessThanEqual(selectorTags)(tags)).to.be.false;
|
||||
it('is false when a tag value is greater than the selector value', function() {
|
||||
var selectorTags = { lanes: 5 };
|
||||
var tags = { lanes: 6 };
|
||||
expect(_ruleChecks.lessThanEqual(selectorTags)(tags)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('positiveRegex', function () {
|
||||
var positiveRegex = { amenity: ['^hospital$', '^clinic$'] };
|
||||
it('is true when tag value matches positiveRegex', function () {
|
||||
describe('positiveRegex', function() {
|
||||
var positiveRegex = { amenity: ['^hospital$','^clinic$']};
|
||||
it('is true when tag value matches positiveRegex', function() {
|
||||
var tags = { amenity: 'hospital' };
|
||||
expect(_ruleChecks.positiveRegex(positiveRegex)(tags)).to.be.true;
|
||||
});
|
||||
it('is false when tag value does not match negative regex', function () {
|
||||
it('is false when tag value does not match negative regex', function() {
|
||||
var tags = { amenity: 'school' };
|
||||
expect(_ruleChecks.positiveRegex(positiveRegex)(tags)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('negativeRegex', function () {
|
||||
var negativeRegex = { bicycle: ['use_path', 'designated'] };
|
||||
it('is true when tag value does not match negativeRegex', function () {
|
||||
describe('negativeRegex', function() {
|
||||
var negativeRegex = { bicycle: [ 'use_path', 'designated' ] };
|
||||
it('is true when tag value does not match negativeRegex', function() {
|
||||
var tags = { bicycle: 'yes' };
|
||||
expect(_ruleChecks.negativeRegex(negativeRegex)(tags)).to.be.true;
|
||||
});
|
||||
it('is false when tag value matches negativeRegex', function () {
|
||||
it('is false when tag value matches negativeRegex', function() {
|
||||
var tags = { bicycle: 'designated' };
|
||||
expect(_ruleChecks.negativeRegex(negativeRegex)(tags)).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('rule', function () {
|
||||
describe('rule', function() {
|
||||
var selectors;
|
||||
before(function () {
|
||||
before(function() {
|
||||
selectors = [
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { amenity: 'marketplace' },
|
||||
absence: 'name',
|
||||
error: '\'Marketplace\' preset must be coupled with name'
|
||||
geometry:'node',
|
||||
equals: {amenity:'marketplace'},
|
||||
absence:'name',
|
||||
error:'\'Marketplace\' preset must be coupled with name'
|
||||
},
|
||||
{
|
||||
geometry: 'closedway',
|
||||
@@ -324,10 +324,10 @@ describe('maprules', function () {
|
||||
error: '\'Clinic\' preset must be coupled with building=yes'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { man_made: 'tower', 'tower:type': 'communication' },
|
||||
geometry:'node',
|
||||
equals: {man_made: 'tower', 'tower:type': 'communication'},
|
||||
presence: 'height',
|
||||
error: '\'Communication Tower\' preset must not be coupled with height'
|
||||
error:'\'Communication Tower\' preset must not be coupled with height'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
@@ -368,18 +368,18 @@ describe('maprules', function () {
|
||||
];
|
||||
|
||||
iD.serviceMapRules.clearRules();
|
||||
selectors.forEach(function (selector) { iD.serviceMapRules.addRule(selector); });
|
||||
selectors.forEach(function(selector) { iD.serviceMapRules.addRule(selector); });
|
||||
validationRules = iD.serviceMapRules.validationRules();
|
||||
});
|
||||
describe('#matches', function () {
|
||||
describe('#matches', function() {
|
||||
var selectors, entities;
|
||||
before(function () {
|
||||
before(function() {
|
||||
selectors = [
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { amenity: 'marketplace' },
|
||||
absence: 'name',
|
||||
error: '\'Marketplace\' preset must be coupled with name'
|
||||
geometry:'node',
|
||||
equals: {amenity:'marketplace'},
|
||||
absence:'name',
|
||||
error:'\'Marketplace\' preset must be coupled with name'
|
||||
},
|
||||
{
|
||||
geometry: 'closedway',
|
||||
@@ -387,10 +387,10 @@ describe('maprules', function () {
|
||||
error: '\'Clinic\' preset must be coupled with building=yes'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { man_made: 'tower', 'tower:type': 'communication' },
|
||||
geometry:'node',
|
||||
equals: {man_made: 'tower', 'tower:type': 'communication'},
|
||||
presence: 'height',
|
||||
error: '\'Communication Tower\' preset must not be coupled with height'
|
||||
error:'\'Communication Tower\' preset must not be coupled with height'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
@@ -430,34 +430,34 @@ describe('maprules', function () {
|
||||
}
|
||||
];
|
||||
entities = [
|
||||
iD.osmEntity({ type: 'node', tags: { amenity: 'marketplace' } }),
|
||||
iD.osmWay({ tags: { building: 'house', amenity: 'clinic' }, nodes: ['a', 'b', 'c', 'a'] }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', 'tower:type': 'communication', height: 5 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 6 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 9 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 5 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 10 } }),
|
||||
iD.osmWay({ tags: { amenity: 'clinic', emergency: 'definitely' }, nodes: ['d', 'e', 'f', 'd'] }),
|
||||
iD.osmWay({ tags: { highway: 'residential', structure: 'bridge' } }),
|
||||
iD.osmEntity({ type: 'node', tags: { amenity: 'marketplace' }}),
|
||||
iD.osmWay({ tags: { building: 'house', amenity: 'clinic' }, nodes: [ 'a', 'b', 'c', 'a' ]}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', 'tower:type': 'communication', height: 5 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 6 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 9 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 5 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 10 }}),
|
||||
iD.osmWay({ tags: { amenity: 'clinic', emergency: 'definitely' }, nodes: [ 'd', 'e', 'f', 'd' ]}),
|
||||
iD.osmWay({ tags: { highway: 'residential', structure: 'bridge' }}),
|
||||
];
|
||||
|
||||
iD.serviceMapRules.clearRules();
|
||||
selectors.forEach(function (selector) { iD.serviceMapRules.addRule(selector); });
|
||||
selectors.forEach(function(selector) { iD.serviceMapRules.addRule(selector); });
|
||||
validationRules = iD.serviceMapRules.validationRules();
|
||||
});
|
||||
it('is true when each rule check is \'true\'', function () {
|
||||
validationRules.forEach(function (rule, i) {
|
||||
it('is true when each rule check is \'true\'', function() {
|
||||
validationRules.forEach(function(rule, i) {
|
||||
expect(rule.matches(entities[i])).to.be.true;
|
||||
});
|
||||
});
|
||||
it('is true when at least one rule check is \'false\'', function () {
|
||||
it('is true when at least one rule check is \'false\'', function() {
|
||||
var selector = {
|
||||
geometry: 'way',
|
||||
equals: { highway: 'residential' },
|
||||
positiveRegex: { structure: ['embarkment', 'bridge'] },
|
||||
error: '\'suburban road\' structure tag cannot be \'bridge\' or \'tunnel\''
|
||||
};
|
||||
var entity = iD.osmWay({ tags: { highway: 'residential', structure: 'tunnel' } });
|
||||
var entity = iD.osmWay({ tags: { highway: 'residential', structure: 'tunnel' }});
|
||||
iD.serviceMapRules.clearRules();
|
||||
iD.serviceMapRules.addRule(selector);
|
||||
var rule = iD.serviceMapRules.validationRules()[0];
|
||||
@@ -465,16 +465,16 @@ describe('maprules', function () {
|
||||
expect(rule.matches(entity)).to.be.false;
|
||||
});
|
||||
});
|
||||
describe('#findIssues', function () {
|
||||
describe('#findIssues', function() {
|
||||
var selectors, entities, _graph;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
selectors = [
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { amenity: 'marketplace' },
|
||||
absence: 'name',
|
||||
error: '\'Marketplace\' preset must be coupled with name'
|
||||
geometry:'node',
|
||||
equals: {amenity:'marketplace'},
|
||||
absence:'name',
|
||||
error:'\'Marketplace\' preset must be coupled with name'
|
||||
},
|
||||
{
|
||||
geometry: 'closedway',
|
||||
@@ -482,10 +482,10 @@ describe('maprules', function () {
|
||||
error: '\'Clinic\' preset must be coupled with building=yes'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
equals: { man_made: 'tower', 'tower:type': 'communication' },
|
||||
geometry:'node',
|
||||
equals: {man_made: 'tower', 'tower:type': 'communication'},
|
||||
presence: 'height',
|
||||
error: '\'Communication Tower\' preset must not be coupled with height'
|
||||
error:'\'Communication Tower\' preset must not be coupled with height'
|
||||
},
|
||||
{
|
||||
geometry: 'node',
|
||||
@@ -525,15 +525,15 @@ describe('maprules', function () {
|
||||
}
|
||||
];
|
||||
entities = [
|
||||
iD.osmEntity({ type: 'node', tags: { amenity: 'marketplace' } }),
|
||||
iD.osmWay({ tags: { building: 'house', amenity: 'clinic' }, nodes: ['a', 'b', 'c', 'a'] }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', 'tower:type': 'communication', height: 5 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 6 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 9 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 5 } }),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 10 } }),
|
||||
iD.osmWay({ tags: { amenity: 'clinic', emergency: 'definitely' }, nodes: ['d', 'e', 'f', 'd'] }),
|
||||
iD.osmWay({ tags: { highway: 'residential', structure: 'bridge' } }),
|
||||
iD.osmEntity({ type: 'node', tags: { amenity: 'marketplace' }}),
|
||||
iD.osmWay({ tags: { building: 'house', amenity: 'clinic' }, nodes: [ 'a', 'b', 'c', 'a' ]}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', 'tower:type': 'communication', height: 5 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 6 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 9 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 5 }}),
|
||||
iD.osmEntity({ type: 'node', tags: { man_made: 'tower', height: 10 }}),
|
||||
iD.osmWay({ tags: { amenity: 'clinic', emergency: 'definitely' }, nodes: [ 'd', 'e', 'f', 'd' ]}),
|
||||
iD.osmWay({ tags: { highway: 'residential', structure: 'bridge' }}),
|
||||
];
|
||||
|
||||
var wayNodes = [
|
||||
@@ -546,11 +546,11 @@ describe('maprules', function () {
|
||||
];
|
||||
_graph = iD.coreGraph(entities.concat(wayNodes));
|
||||
iD.serviceMapRules.clearRules();
|
||||
selectors.forEach(function (selector) { iD.serviceMapRules.addRule(selector); });
|
||||
selectors.forEach(function(selector) { iD.serviceMapRules.addRule(selector); });
|
||||
validationRules = iD.serviceMapRules.validationRules();
|
||||
});
|
||||
it('finds issues', function () {
|
||||
validationRules.forEach(function (rule, i) {
|
||||
it('finds issues', function() {
|
||||
validationRules.forEach(function(rule, i) {
|
||||
var issues = [];
|
||||
var entity = entities[i];
|
||||
var selector = selectors[i];
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
describe('iD.serviceNominatim', function () {
|
||||
describe('iD.serviceNominatim', function() {
|
||||
var nominatim;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.geocoder = iD.serviceNominatim;
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.geocoder;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
nominatim = iD.services.geocoder;
|
||||
nominatim.reset();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
@@ -23,8 +23,8 @@ describe('iD.serviceNominatim', function () {
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?')));
|
||||
}
|
||||
|
||||
describe('#countryCode', function () {
|
||||
it('calls the given callback with the results of the country code query', function (done) {
|
||||
describe('#countryCode', function() {
|
||||
it('calls the given callback with the results of the country code query', function(done) {
|
||||
var callback = sinon.spy();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/reverse'), {
|
||||
body: '{"address":{"country_code":"at"}}',
|
||||
@@ -34,9 +34,9 @@ describe('iD.serviceNominatim', function () {
|
||||
|
||||
nominatim.countryCode([16, 48], callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16' }
|
||||
{zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWithExactly(null, 'at');
|
||||
done();
|
||||
@@ -44,8 +44,8 @@ describe('iD.serviceNominatim', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reverse', function () {
|
||||
it('should not cache distant result', function (done) {
|
||||
describe('#reverse', function() {
|
||||
it('should not cache distant result', function(done) {
|
||||
var callback = sinon.spy();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/reverse'), {
|
||||
body: '{"address":{"country_code":"at"}}',
|
||||
@@ -55,11 +55,11 @@ describe('iD.serviceNominatim', function () {
|
||||
|
||||
nominatim.reverse([16, 48], callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16' }
|
||||
{zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWithExactly(null, { address: { country_code: 'at' } });
|
||||
expect(callback).to.have.been.calledWithExactly(null, {address: {country_code:'at'}});
|
||||
|
||||
fetchMock.reset();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/reverse'), {
|
||||
@@ -71,17 +71,17 @@ describe('iD.serviceNominatim', function () {
|
||||
callback = sinon.spy();
|
||||
nominatim.reverse([17, 49], callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ zoom: '13', format: 'json', addressdetails: '1', lat: '49', lon: '17' }
|
||||
{zoom: '13', format: 'json', addressdetails: '1', lat: '49', lon: '17'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWithExactly(null, { address: { country_code: 'cz' } });
|
||||
expect(callback).to.have.been.calledWithExactly(null, {address: {country_code:'cz'}});
|
||||
done();
|
||||
}, 50);
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('should cache nearby result', function (done) {
|
||||
it('should cache nearby result', function(done) {
|
||||
var callback = sinon.spy();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/reverse'), {
|
||||
body: '{"address":{"country_code":"at"}}',
|
||||
@@ -91,25 +91,25 @@ describe('iD.serviceNominatim', function () {
|
||||
|
||||
nominatim.reverse([16, 48], callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16' }
|
||||
{zoom: '13', format: 'json', addressdetails: '1', lat: '48', lon: '16'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWithExactly(null, { address: { country_code: 'at' } });
|
||||
expect(callback).to.have.been.calledWithExactly(null, {address: {country_code:'at'}});
|
||||
|
||||
fetchMock.resetHistory();
|
||||
|
||||
callback = sinon.spy();
|
||||
nominatim.reverse([16.000001, 48.000001], callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
expect(callback).to.have.been.calledWithExactly(null, { address: { country_code: 'at' } });
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWithExactly(null, {address: {country_code:'at'}});
|
||||
done();
|
||||
}, 50);
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('calls the given callback with an error', function (done) {
|
||||
it('calls the given callback with an error', function(done) {
|
||||
var callback = sinon.spy();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/reverse'), {
|
||||
body: '{"error":"Unable to geocode"}',
|
||||
@@ -120,9 +120,9 @@ describe('iD.serviceNominatim', function () {
|
||||
nominatim.reverse([1000, 1000], callback);
|
||||
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ zoom: '13', format: 'json', addressdetails: '1', lat: '1000', lon: '1000' }
|
||||
{zoom: '13', format: 'json', addressdetails: '1', lat: '1000', lon: '1000'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWithExactly('Unable to geocode');
|
||||
done();
|
||||
@@ -131,8 +131,8 @@ describe('iD.serviceNominatim', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#search', function () {
|
||||
it('calls the given callback with the results of the search query', function (done) {
|
||||
describe('#search', function() {
|
||||
it('calls the given callback with the results of the search query', function(done) {
|
||||
var callback = sinon.spy();
|
||||
fetchMock.mock(new RegExp('https://nominatim.openstreetmap.org/search'), {
|
||||
body: '[{"place_id":"158484588","osm_type":"relation","osm_id":"188022","boundingbox":["39.867005","40.1379593","-75.2802976","-74.9558313"],"lat":"39.9523993","lon":"-75.1635898","display_name":"Philadelphia, Philadelphia County, Pennsylvania, United States of America","class":"place","type":"city","importance":0.83238050437778}]',
|
||||
@@ -142,8 +142,8 @@ describe('iD.serviceNominatim', function () {
|
||||
|
||||
nominatim.search('philadelphia', callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql({ format: 'json', limit: '10' });
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql({format: 'json', limit: '10'});
|
||||
expect(callback).to.have.been.calledOnce;
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
describe('iD.serviceOpenstreetcam', function () {
|
||||
describe('iD.serviceOpenstreetcam', function() {
|
||||
var dimensions = [64, 64];
|
||||
var context, openstreetcam;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.openstreetcam = iD.serviceOpenstreetcam;
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.openstreetcam;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
context = iD.coreContext().assetPath('../dist/').init();
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(14))
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
openstreetcam = iD.services.openstreetcam;
|
||||
openstreetcam.reset();
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
|
||||
describe('#init', function () {
|
||||
it('Initializes cache one time', function () {
|
||||
describe('#init', function() {
|
||||
it('Initializes cache one time', function() {
|
||||
var cache = openstreetcam.cache();
|
||||
expect(cache).to.have.property('images');
|
||||
expect(cache).to.have.property('sequences');
|
||||
@@ -40,10 +40,10 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reset', function () {
|
||||
it('resets cache and image', function () {
|
||||
describe('#reset', function() {
|
||||
it('resets cache and image', function() {
|
||||
openstreetcam.cache().foo = 'bar';
|
||||
openstreetcam.selectImage(context, { key: 'baz' });
|
||||
openstreetcam.selectImage(context, {key: 'baz'});
|
||||
|
||||
openstreetcam.reset();
|
||||
expect(openstreetcam.cache()).to.not.have.property('foo');
|
||||
@@ -51,11 +51,11 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#loadImages', function () {
|
||||
it('fires loadedImages when images are loaded', function (done) {
|
||||
describe('#loadImages', function() {
|
||||
it('fires loadedImages when images are loaded', function(done) {
|
||||
var data = {
|
||||
status: { apiCode: '600', httpCode: 200, httpMessage: 'Success' },
|
||||
currentPageItems: [{
|
||||
currentPageItems:[{
|
||||
id: '1',
|
||||
sequence_id: '100',
|
||||
sequence_index: '1',
|
||||
@@ -101,7 +101,7 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
openstreetcam.on('loadedImages', function () {
|
||||
openstreetcam.on('loadedImages', function() {
|
||||
expect(fetchMock.calls().length).to.eql(1); // 1 nearby-photos
|
||||
done();
|
||||
});
|
||||
@@ -112,7 +112,7 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
it('does not load images around null island', function (done) {
|
||||
var data = {
|
||||
status: { apiCode: '600', httpCode: 200, httpMessage: 'Success' },
|
||||
currentPageItems: [{
|
||||
currentPageItems:[{
|
||||
id: '1',
|
||||
sequence_id: '100',
|
||||
sequence_index: '1',
|
||||
@@ -164,14 +164,14 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
openstreetcam.on('loadedImages', spy);
|
||||
openstreetcam.loadImages(context.projection);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(spy).to.have.been.not.called;
|
||||
expect(fetchMock.calls().length).to.eql(0); // no tile requests of any kind
|
||||
done();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
it('loads multiple pages of image results', function (done) {
|
||||
it('loads multiple pages of image results', function(done) {
|
||||
var features = [];
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var key = String(i);
|
||||
@@ -202,7 +202,7 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
openstreetcam.on('loadedImages', function () {
|
||||
openstreetcam.on('loadedImages', function() {
|
||||
expect(fetchMock.calls().length).to.eql(2); // 2 nearby-photos
|
||||
done();
|
||||
});
|
||||
@@ -212,31 +212,31 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#images', function () {
|
||||
it('returns images in the visible map area', function () {
|
||||
describe('#images', function() {
|
||||
it('returns images in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1], ca: 90, sequence_id: '100', sequence_index: 2 } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], ca: 90, sequence_id: '100', sequence_index: 2 } }
|
||||
];
|
||||
|
||||
openstreetcam.cache().images.rtree.load(features);
|
||||
var res = openstreetcam.images(context.projection);
|
||||
|
||||
expect(res).to.deep.eql([
|
||||
{ key: '0', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 0 },
|
||||
{ key: '1', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 1 }
|
||||
{ key: '0', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 0 },
|
||||
{ key: '1', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 1 }
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits results no more than 5 stacked images in one spot', function () {
|
||||
it('limits results no more than 5 stacked images in one spot', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 2 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 3 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 4 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 5 } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '2', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 2 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '3', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 3 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 4 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '5', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 5 } }
|
||||
];
|
||||
|
||||
openstreetcam.cache().images.rtree.load(features);
|
||||
@@ -246,21 +246,21 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#sequences', function () {
|
||||
it('returns sequence linestrings in the visible map area', function () {
|
||||
describe('#sequences', function() {
|
||||
it('returns sequence linestrings in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1], ca: 90, sequence_id: '100', sequence_index: 2 } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 0 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0], ca: 90, sequence_id: '100', sequence_index: 1 } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], ca: 90, sequence_id: '100', sequence_index: 2 } }
|
||||
];
|
||||
|
||||
openstreetcam.cache().images.rtree.load(features);
|
||||
openstreetcam.cache().sequences['100'] = { rotation: 0, images: [features[0].data, features[1].data, features[2].data] };
|
||||
openstreetcam.cache().sequences['100'] = { rotation: 0, images: [ features[0].data, features[1].data, features[2].data ] };
|
||||
|
||||
var res = openstreetcam.sequences(context.projection);
|
||||
expect(res).to.deep.eql([{
|
||||
type: 'LineString',
|
||||
coordinates: [[10, 0], [10, 0], [10, 1]],
|
||||
coordinates: [[10,0], [10,0], [10,1]],
|
||||
properties: {
|
||||
captured_at: undefined,
|
||||
captured_by: undefined,
|
||||
@@ -270,10 +270,10 @@ describe('iD.serviceOpenstreetcam', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#selectedImage', function () {
|
||||
it('sets and gets selected image', function () {
|
||||
describe('#selectedImage', function() {
|
||||
it('sets and gets selected image', function() {
|
||||
var d = { key: 'foo' };
|
||||
openstreetcam.cache().images = { forImageKey: { foo: d } };
|
||||
openstreetcam.cache().images = { forImageKey: { foo: d }};
|
||||
openstreetcam.selectImage(context, 'foo');
|
||||
expect(openstreetcam.getSelectedImage()).to.eql(d);
|
||||
});
|
||||
|
||||
@@ -16,11 +16,11 @@ describe('iD.serviceOsm', function () {
|
||||
connection.logout();
|
||||
}
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.osm = iD.serviceOsm;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.osm;
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('iD.serviceOsm', function () {
|
||||
spy = sinon.spy();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
fetchMock.reset();
|
||||
serverXHR.restore();
|
||||
});
|
||||
@@ -44,8 +44,8 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#getConnectionId', function () {
|
||||
it('changes the connection id every time connection is reset', function () {
|
||||
describe('#getConnectionId', function() {
|
||||
it('changes the connection id every time connection is reset', function() {
|
||||
var cid1 = connection.getConnectionId();
|
||||
connection.reset();
|
||||
var cid2 = connection.getConnectionId();
|
||||
@@ -60,78 +60,78 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#changesetURL', function () {
|
||||
it('provides a changeset url', function () {
|
||||
describe('#changesetURL', function() {
|
||||
it('provides a changeset url', function() {
|
||||
expect(connection.changesetURL(2)).to.eql('http://www.openstreetmap.org/changeset/2');
|
||||
});
|
||||
|
||||
it('allows secure connections', function () {
|
||||
it('allows secure connections', function() {
|
||||
connection.switch({ urlroot: 'https://www.openstreetmap.org' });
|
||||
expect(connection.changesetURL(2)).to.eql('https://www.openstreetmap.org/changeset/2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#changesetsURL', function () {
|
||||
it('provides a local changesets url', function () {
|
||||
describe('#changesetsURL', function() {
|
||||
it('provides a local changesets url', function() {
|
||||
var center = [-74.65, 40.65];
|
||||
var zoom = 17;
|
||||
expect(connection.changesetsURL(center, zoom)).to.eql('http://www.openstreetmap.org/history#map=17/40.65000/-74.65000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#entityURL', function () {
|
||||
it('provides an entity url for a node', function () {
|
||||
var e = iD.osmNode({ id: 'n1' });
|
||||
describe('#entityURL', function() {
|
||||
it('provides an entity url for a node', function() {
|
||||
var e = iD.osmNode({id: 'n1'});
|
||||
expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/node/1');
|
||||
});
|
||||
|
||||
it('provides an entity url for a way', function () {
|
||||
var e = iD.osmWay({ id: 'w1' });
|
||||
it('provides an entity url for a way', function() {
|
||||
var e = iD.osmWay({id: 'w1'});
|
||||
expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/way/1');
|
||||
});
|
||||
|
||||
it('provides an entity url for a relation', function () {
|
||||
var e = iD.osmRelation({ id: 'r1' });
|
||||
it('provides an entity url for a relation', function() {
|
||||
var e = iD.osmRelation({id: 'r1'});
|
||||
expect(connection.entityURL(e)).to.eql('http://www.openstreetmap.org/relation/1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#historyURL', function () {
|
||||
it('provides a history url for a node', function () {
|
||||
var e = iD.osmNode({ id: 'n1' });
|
||||
describe('#historyURL', function() {
|
||||
it('provides a history url for a node', function() {
|
||||
var e = iD.osmNode({id: 'n1'});
|
||||
expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/node/1/history');
|
||||
});
|
||||
|
||||
it('provides a history url for a way', function () {
|
||||
var e = iD.osmWay({ id: 'w1' });
|
||||
it('provides a history url for a way', function() {
|
||||
var e = iD.osmWay({id: 'w1'});
|
||||
expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/way/1/history');
|
||||
});
|
||||
|
||||
it('provides a history url for a relation', function () {
|
||||
var e = iD.osmRelation({ id: 'r1' });
|
||||
it('provides a history url for a relation', function() {
|
||||
var e = iD.osmRelation({id: 'r1'});
|
||||
expect(connection.historyURL(e)).to.eql('http://www.openstreetmap.org/relation/1/history');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#userURL', function () {
|
||||
it('provides a user url', function () {
|
||||
describe('#userURL', function() {
|
||||
it('provides a user url', function() {
|
||||
expect(connection.userURL('bob')).to.eql('http://www.openstreetmap.org/user/bob');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reset', function () {
|
||||
it('resets the connection', function () {
|
||||
describe('#reset', function() {
|
||||
it('resets the connection', function() {
|
||||
expect(connection.reset()).to.eql(connection);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#switch', function () {
|
||||
it('changes the URL', function () {
|
||||
describe('#switch', function() {
|
||||
it('changes the URL', function() {
|
||||
connection.switch({ urlroot: 'http://example.com' });
|
||||
expect(connection.changesetURL(1)).to.equal('http://example.com/changeset/1');
|
||||
});
|
||||
|
||||
it('emits a change event', function () {
|
||||
it('emits a change event', function() {
|
||||
connection.on('change', spy);
|
||||
connection.switch({ urlroot: 'http://example.com' });
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
@@ -151,7 +151,7 @@ describe('iD.serviceOsm', function () {
|
||||
' ]' +
|
||||
'}';
|
||||
|
||||
it('returns an object', function (done) {
|
||||
it('returns an object', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org' + path, {
|
||||
body: response,
|
||||
status: 200,
|
||||
@@ -267,7 +267,7 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#loadTiles', function () {
|
||||
describe('#loadTiles', function() {
|
||||
var tileResponse =
|
||||
'{' +
|
||||
' "version":"0.6",' +
|
||||
@@ -277,15 +277,15 @@ describe('iD.serviceOsm', function () {
|
||||
' ]' +
|
||||
'}';
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
var dimensions = [64, 64];
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(20))
|
||||
.translate([55212042.434589595, 33248879.510193843]) // -74.0444216, 40.6694299
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
});
|
||||
|
||||
it('calls callback when data tiles are loaded', function (done) {
|
||||
it('calls callback when data tiles are loaded', function(done) {
|
||||
fetchMock.mock(/map.json\?bbox/, {
|
||||
body: tileResponse,
|
||||
status: 200,
|
||||
@@ -295,13 +295,13 @@ describe('iD.serviceOsm', function () {
|
||||
var spy = sinon.spy();
|
||||
connection.loadTiles(context.projection, spy);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('#isDataLoaded', function (done) {
|
||||
it('#isDataLoaded', function(done) {
|
||||
fetchMock.mock(/map.json\?bbox/, {
|
||||
body: tileResponse,
|
||||
status: 200,
|
||||
@@ -320,7 +320,7 @@ describe('iD.serviceOsm', function () {
|
||||
|
||||
connection.loadTiles(context.projection);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(fetchMock.called()).to.be.true;
|
||||
expect(connection.isDataLoaded([-74.0444216, 40.6694299])).to.be.true;
|
||||
done();
|
||||
@@ -346,7 +346,7 @@ describe('iD.serviceOsm', function () {
|
||||
' ]' +
|
||||
'}';
|
||||
|
||||
it('loads a node', function (done) {
|
||||
it('loads a node', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/node/1.json', {
|
||||
body: nodeResponse,
|
||||
status: 200,
|
||||
@@ -354,14 +354,14 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'n1';
|
||||
connection.loadEntity(id, function (err, result) {
|
||||
var entity = result.data.find(function (e) { return e.id === id; });
|
||||
connection.loadEntity(id, function(err, result) {
|
||||
var entity = result.data.find(function(e) { return e.id === id; });
|
||||
expect(entity).to.be.an.instanceOf(iD.osmNode);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('loads a way', function (done) {
|
||||
it('loads a way', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/way/1/full.json', {
|
||||
body: wayResponse,
|
||||
status: 200,
|
||||
@@ -369,14 +369,14 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'w1';
|
||||
connection.loadEntity(id, function (err, result) {
|
||||
var entity = result.data.find(function (e) { return e.id === id; });
|
||||
connection.loadEntity(id, function(err, result) {
|
||||
var entity = result.data.find(function(e) { return e.id === id; });
|
||||
expect(entity).to.be.an.instanceOf(iD.osmWay);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not ignore repeat requests', function (done) {
|
||||
it('does not ignore repeat requests', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/node/1.json', {
|
||||
body: wayResponse,
|
||||
status: 200,
|
||||
@@ -384,12 +384,12 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'n1';
|
||||
connection.loadEntity(id, function (err1, result1) {
|
||||
var entity1 = result1.data.find(function (e1) { return e1.id === id; });
|
||||
connection.loadEntity(id, function(err1, result1) {
|
||||
var entity1 = result1.data.find(function(e1) { return e1.id === id; });
|
||||
expect(entity1).to.be.an.instanceOf(iD.osmNode);
|
||||
|
||||
connection.loadEntity(id, function (err2, result2) {
|
||||
var entity2 = result2.data.find(function (e2) { return e2.id === id; });
|
||||
connection.loadEntity(id, function(err2, result2) {
|
||||
var entity2 = result2.data.find(function(e2) { return e2.id === id; });
|
||||
expect(entity2).to.be.an.instanceOf(iD.osmNode);
|
||||
done();
|
||||
});
|
||||
@@ -415,7 +415,7 @@ describe('iD.serviceOsm', function () {
|
||||
' ]' +
|
||||
'}';
|
||||
|
||||
it('loads a node', function (done) {
|
||||
it('loads a node', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/node/1/1.json', {
|
||||
body: nodeResponse,
|
||||
status: 200,
|
||||
@@ -423,14 +423,14 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'n1';
|
||||
connection.loadEntityVersion(id, 1, function (err, result) {
|
||||
var entity = result.data.find(function (e) { return e.id === id; });
|
||||
connection.loadEntityVersion(id, 1, function(err, result) {
|
||||
var entity = result.data.find(function(e) { return e.id === id; });
|
||||
expect(entity).to.be.an.instanceOf(iD.osmNode);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('loads a way', function (done) {
|
||||
it('loads a way', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/way/1/1.json', {
|
||||
body: wayResponse,
|
||||
status: 200,
|
||||
@@ -438,14 +438,14 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'w1';
|
||||
connection.loadEntityVersion(id, 1, function (err, result) {
|
||||
var entity = result.data.find(function (e) { return e.id === id; });
|
||||
connection.loadEntityVersion(id, 1, function(err, result) {
|
||||
var entity = result.data.find(function(e) { return e.id === id; });
|
||||
expect(entity).to.be.an.instanceOf(iD.osmWay);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not ignore repeat requests', function (done) {
|
||||
it('does not ignore repeat requests', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/0.6/node/1/1.json', {
|
||||
body: nodeResponse,
|
||||
status: 200,
|
||||
@@ -453,11 +453,12 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
var id = 'n1';
|
||||
connection.loadEntityVersion(id, 1, function (err1, result1) {
|
||||
var entity1 = result1.data.find(function (e1) { return e1.id === id; });
|
||||
connection.loadEntityVersion(id, 1, function(err1, result1) {
|
||||
var entity1 = result1.data.find(function(e1) { return e1.id === id; });
|
||||
expect(entity1).to.be.an.instanceOf(iD.osmNode);
|
||||
connection.loadEntityVersion(id, 1, function (err2, result2) {
|
||||
var entity2 = result2.data.find(function (e2) { return e2.id === id; });
|
||||
|
||||
connection.loadEntityVersion(id, 1, function(err2, result2) {
|
||||
var entity2 = result2.data.find(function(e2) { return e2.id === id; });
|
||||
expect(entity2).to.be.an.instanceOf(iD.osmNode);
|
||||
done();
|
||||
});
|
||||
@@ -473,22 +474,22 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#userChangesets', function () {
|
||||
describe('#userChangesets', function() {
|
||||
var userDetailsFn;
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
userDetailsFn = connection.userDetails;
|
||||
connection.userDetails = function (callback) {
|
||||
callback(undefined, { id: 1, displayName: 'Steve' });
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
connection.userDetails = userDetailsFn;
|
||||
});
|
||||
|
||||
|
||||
it('loads user changesets', function (done) {
|
||||
it('loads user changesets', function(done) {
|
||||
var changesetsXML = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm>' +
|
||||
'<changeset id="36777543" user="Steve" uid="1" created_at="2016-01-24T15:02:06Z" closed_at="2016-01-24T15:02:07Z" open="false" min_lat="39.3823819" min_lon="-104.8639728" max_lat="39.3834184" max_lon="-104.8618622" comments_count="0">' +
|
||||
@@ -498,7 +499,7 @@ describe('iD.serviceOsm', function () {
|
||||
'</osm>';
|
||||
|
||||
login();
|
||||
connection.userChangesets(function (err, changesets) {
|
||||
connection.userChangesets(function(err, changesets) {
|
||||
expect(changesets).to.deep.equal([{
|
||||
tags: {
|
||||
comment: 'Caprice Court has been extended',
|
||||
@@ -514,7 +515,7 @@ describe('iD.serviceOsm', function () {
|
||||
serverXHR.respond();
|
||||
});
|
||||
|
||||
it('excludes changesets without comment tag', function (done) {
|
||||
it('excludes changesets without comment tag', function(done) {
|
||||
var changesetsXML = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm>' +
|
||||
'<changeset id="36777543" user="Steve" uid="1" created_at="2016-01-24T15:02:06Z" closed_at="2016-01-24T15:02:07Z" open="false" min_lat="39.3823819" min_lon="-104.8639728" max_lat="39.3834184" max_lon="-104.8618622" comments_count="0">' +
|
||||
@@ -527,7 +528,7 @@ describe('iD.serviceOsm', function () {
|
||||
'</osm>';
|
||||
|
||||
login();
|
||||
connection.userChangesets(function (err, changesets) {
|
||||
connection.userChangesets(function(err, changesets) {
|
||||
expect(changesets).to.deep.equal([{
|
||||
tags: {
|
||||
comment: 'Caprice Court has been extended',
|
||||
@@ -543,7 +544,7 @@ describe('iD.serviceOsm', function () {
|
||||
serverXHR.respond();
|
||||
});
|
||||
|
||||
it('excludes changesets with empty comment', function (done) {
|
||||
it('excludes changesets with empty comment', function(done) {
|
||||
var changesetsXML = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm>' +
|
||||
'<changeset id="36777543" user="Steve" uid="1" created_at="2016-01-24T15:02:06Z" closed_at="2016-01-24T15:02:07Z" open="false" min_lat="39.3823819" min_lon="-104.8639728" max_lat="39.3834184" max_lon="-104.8618622" comments_count="0">' +
|
||||
@@ -557,7 +558,7 @@ describe('iD.serviceOsm', function () {
|
||||
'</osm>';
|
||||
|
||||
login();
|
||||
connection.userChangesets(function (err, changesets) {
|
||||
connection.userChangesets(function(err, changesets) {
|
||||
expect(changesets).to.deep.equal([{
|
||||
tags: {
|
||||
comment: 'Caprice Court has been extended',
|
||||
@@ -574,15 +575,15 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#caches', function () {
|
||||
describe('#caches', function() {
|
||||
it('loads reset caches', function () {
|
||||
var caches = connection.caches();
|
||||
expect(caches.tile).to.have.all.keys(['toLoad', 'loaded', 'inflight', 'seen', 'rtree']);
|
||||
expect(caches.note).to.have.all.keys(['toLoad', 'loaded', 'inflight', 'inflightPost', 'note', 'closed', 'rtree']);
|
||||
expect(caches.user).to.have.all.keys(['toLoad', 'user']);
|
||||
expect(caches.tile).to.have.all.keys(['toLoad','loaded','inflight','seen','rtree']);
|
||||
expect(caches.note).to.have.all.keys(['toLoad','loaded','inflight','inflightPost','note','closed','rtree']);
|
||||
expect(caches.user).to.have.all.keys(['toLoad','user']);
|
||||
});
|
||||
|
||||
describe('sets/gets caches', function () {
|
||||
describe('sets/gets caches', function() {
|
||||
it('sets/gets a tile', function () {
|
||||
var obj = {
|
||||
tile: { loaded: { '1,2,16': true, '3,4,16': true } }
|
||||
@@ -617,7 +618,7 @@ describe('iD.serviceOsm', function () {
|
||||
|
||||
});
|
||||
|
||||
describe('#loadNotes', function () {
|
||||
describe('#loadNotes', function() {
|
||||
var notesXML = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm>' +
|
||||
'<note lon="10" lat="0">' +
|
||||
@@ -641,15 +642,15 @@ describe('iD.serviceOsm', function () {
|
||||
'</note>' +
|
||||
'</osm>';
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
var dimensions = [64, 64];
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(14))
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
});
|
||||
|
||||
it('fires loadedNotes when notes are loaded', function (done) {
|
||||
it('fires loadedNotes when notes are loaded', function(done) {
|
||||
fetchMock.mock(/notes\?/, {
|
||||
body: notesXML,
|
||||
status: 200,
|
||||
@@ -659,7 +660,7 @@ describe('iD.serviceOsm', function () {
|
||||
connection.on('loadedNotes', spy);
|
||||
connection.loadNotes(context.projection, {});
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
done();
|
||||
}, 500);
|
||||
@@ -667,34 +668,34 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#notes', function () {
|
||||
beforeEach(function () {
|
||||
describe('#notes', function() {
|
||||
beforeEach(function() {
|
||||
var dimensions = [64, 64];
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(14))
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
});
|
||||
|
||||
it('returns notes in the visible map area', function () {
|
||||
it('returns notes in the visible map area', function() {
|
||||
var notes = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10, 0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10, 1] } }
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '0', loc: [10,0] } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '1', loc: [10,0] } },
|
||||
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1] } }
|
||||
];
|
||||
|
||||
connection.caches('get').note.rtree.load(notes);
|
||||
var res = connection.notes(context.projection);
|
||||
|
||||
expect(res).to.deep.eql([
|
||||
{ key: '0', loc: [10, 0] },
|
||||
{ key: '1', loc: [10, 0] }
|
||||
{ key: '0', loc: [10,0] },
|
||||
{ key: '1', loc: [10,0] }
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#getNote', function () {
|
||||
describe('#getNote', function() {
|
||||
it('returns a note', function () {
|
||||
var note = iD.osmNote({ id: 1, loc: [0, 0], });
|
||||
var obj = {
|
||||
@@ -706,8 +707,8 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#removeNote', function () {
|
||||
it('removes a note that is new', function () {
|
||||
describe('#removeNote', function() {
|
||||
it('removes a note that is new', function() {
|
||||
var note = iD.osmNote({ id: -1, loc: [0, 0], });
|
||||
connection.replaceNote(note);
|
||||
connection.removeNote(note);
|
||||
@@ -717,7 +718,7 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#replaceNote', function () {
|
||||
describe('#replaceNote', function() {
|
||||
it('returns a new note', function () {
|
||||
var note = iD.osmNote({ id: 2, loc: [0, 0], });
|
||||
var result = connection.replaceNote(note);
|
||||
@@ -744,7 +745,7 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('API capabilities', function () {
|
||||
describe('API capabilities', function() {
|
||||
var capabilitiesXML = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
|
||||
<api>
|
||||
@@ -765,8 +766,8 @@ describe('iD.serviceOsm', function () {
|
||||
</policy>
|
||||
</osm>`;
|
||||
|
||||
describe('#status', function () {
|
||||
it('gets API status', function (done) {
|
||||
describe('#status', function() {
|
||||
it('gets API status', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/capabilities', {
|
||||
body: capabilitiesXML,
|
||||
status: 200,
|
||||
@@ -782,8 +783,8 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#imageryBlocklists', function () {
|
||||
it('updates imagery blocklists', function (done) {
|
||||
describe('#imageryBlocklists', function() {
|
||||
it('updates imagery blocklists', function(done) {
|
||||
fetchMock.mock('http://www.openstreetmap.org/api/capabilities', {
|
||||
body: capabilitiesXML,
|
||||
status: 200,
|
||||
@@ -792,7 +793,7 @@ describe('iD.serviceOsm', function () {
|
||||
overwriteRoutes: true
|
||||
});
|
||||
|
||||
connection.status(function () {
|
||||
connection.status(function() {
|
||||
var blocklists = connection.imageryBlocklists();
|
||||
expect(blocklists).to.deep.equal([new RegExp('\.foo\.com'), new RegExp('\.bar\.org')]);
|
||||
done();
|
||||
@@ -801,5 +802,4 @@ describe('iD.serviceOsm', function () {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -33,10 +33,10 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
type: 'item',
|
||||
id: 'Q42',
|
||||
labels: {
|
||||
fr: { language: 'en', value: 'amenity', 'for-language': 'fr' }
|
||||
fr: {language: 'en', value: 'amenity', 'for-language': 'fr'}
|
||||
},
|
||||
descriptions: {
|
||||
fr: { language: 'en', value: 'English description', 'for-language': 'fr' }
|
||||
fr: {language: 'en', value: 'English description', 'for-language': 'fr'}
|
||||
},
|
||||
aliases: {},
|
||||
claims: {
|
||||
@@ -45,7 +45,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q7' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q7'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -56,7 +56,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'string',
|
||||
datavalue: { value: 'amenity', type: 'string' }
|
||||
datavalue: {value: 'amenity', type: 'string'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -67,7 +67,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q4679' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q4679'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -78,7 +78,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q8' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q8'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -89,7 +89,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q15' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q15'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'preferred'
|
||||
@@ -98,7 +98,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q14' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q14'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
qualifiers: {
|
||||
@@ -106,7 +106,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
{
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q6994' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q6994'}, type: 'wikibase-entityid'}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -118,7 +118,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'string',
|
||||
datavalue: { value: 'Mapping-Features-Parking-Lot.png', type: 'string' }
|
||||
datavalue: {value: 'Mapping-Features-Parking-Lot.png', type: 'string'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -145,10 +145,10 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
type: 'item',
|
||||
id: 'Q13',
|
||||
labels: {
|
||||
fr: { language: 'en', value: 'amenity=parking', 'for-language': 'fr' }
|
||||
fr: {language: 'en', value: 'amenity=parking', 'for-language': 'fr'}
|
||||
},
|
||||
descriptions: {
|
||||
fr: { language: 'fr', value: 'French description' }
|
||||
fr: {language: 'fr', value: 'French description'}
|
||||
},
|
||||
aliases: {},
|
||||
claims: {
|
||||
@@ -157,7 +157,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q2' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q2'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -168,7 +168,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'string',
|
||||
datavalue: { value: 'amenity=parking', type: 'string' }
|
||||
datavalue: {value: 'amenity=parking', type: 'string'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -179,7 +179,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q42' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q42'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
@@ -190,7 +190,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'commonsMedia',
|
||||
datavalue: { value: 'Primary image.jpg', type: 'string' }
|
||||
datavalue: {value: 'Primary image.jpg', type: 'string'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'preferred'
|
||||
@@ -201,7 +201,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q14' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q14'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'preferred'
|
||||
@@ -210,7 +210,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q13' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q13'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
qualifiers: {
|
||||
@@ -218,7 +218,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
{
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q6994' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q6994'}, type: 'wikibase-entityid'}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -230,19 +230,19 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
mainsnak: {
|
||||
snaktype: 'value',
|
||||
datatype: 'wikibase-item',
|
||||
datavalue: { value: { 'entity-type': 'item', id: 'Q4679' }, type: 'wikibase-entityid' }
|
||||
datavalue: {value: {'entity-type': 'item', id: 'Q4679'}, type: 'wikibase-entityid'}
|
||||
},
|
||||
type: 'statement',
|
||||
rank: 'normal'
|
||||
}
|
||||
],
|
||||
P31: [
|
||||
{ mainsnak: { datavalue: { value: { text: 'Cs:Key:bridge:movable', language: 'cs' } } } },
|
||||
{ mainsnak: { datavalue: { value: { text: 'DE:Key:bridge:movable', language: 'de' } } } },
|
||||
{ mainsnak: { datavalue: { value: { text: 'FR:Key:bridge:movable', language: 'fr' } } } },
|
||||
{ mainsnak: { datavalue: { value: { text: 'JA:Key:bridge:movable', language: 'ja' } } } },
|
||||
{ mainsnak: { datavalue: { value: { text: 'Pl:Key:bridge:movable', language: 'pl' } } } },
|
||||
{ mainsnak: { datavalue: { value: { text: 'Key:bridge:movable', language: 'en' } } } },
|
||||
{mainsnak: {datavalue: {value: {text: 'Cs:Key:bridge:movable', language: 'cs'}}}},
|
||||
{mainsnak: {datavalue: {value: {text: 'DE:Key:bridge:movable', language: 'de'}}}},
|
||||
{mainsnak: {datavalue: {value: {text: 'FR:Key:bridge:movable', language: 'fr'}}}},
|
||||
{mainsnak: {datavalue: {value: {text: 'JA:Key:bridge:movable', language: 'ja'}}}},
|
||||
{mainsnak: {datavalue: {value: {text: 'Pl:Key:bridge:movable', language: 'pl'}}}},
|
||||
{mainsnak: {datavalue: {value: {text: 'Key:bridge:movable', language: 'en'}}}},
|
||||
],
|
||||
},
|
||||
sitelinks: {
|
||||
@@ -258,7 +258,7 @@ describe('iD.serviceOsmWikibase', function () {
|
||||
|
||||
var localeData = {
|
||||
id: 'Q7792',
|
||||
sitelinks: { wiki: { site: 'wiki', title: 'Locale:fr' } }
|
||||
sitelinks: {wiki: {site: 'wiki', title: 'Locale:fr'}}
|
||||
};
|
||||
|
||||
describe('#getEntity', function () {
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
describe('iD.serviceStreetside', function () {
|
||||
describe('iD.serviceStreetside', function() {
|
||||
var dimensions = [64, 64];
|
||||
var context, streetside;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.streetside = iD.serviceStreetside;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.streetside;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
context = iD.coreContext().assetPath('../dist/').init();
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(14))
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
streetside = iD.services.streetside;
|
||||
streetside.reset();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
window.JSONP_FIX = undefined;
|
||||
});
|
||||
|
||||
|
||||
describe('#init', function () {
|
||||
it('Initializes cache one time', function () {
|
||||
describe('#init', function() {
|
||||
it('Initializes cache one time', function() {
|
||||
var cache = streetside.cache();
|
||||
expect(cache).to.have.property('bubbles');
|
||||
expect(cache).to.have.property('sequences');
|
||||
@@ -38,82 +38,82 @@ describe('iD.serviceStreetside', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reset', function () {
|
||||
it('resets cache', function () {
|
||||
describe('#reset', function() {
|
||||
it('resets cache', function() {
|
||||
streetside.cache().foo = 'bar';
|
||||
streetside.reset();
|
||||
expect(streetside.cache()).to.not.have.property('foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#loadBubbles', function () {
|
||||
it('fires loadedImages when bubbles are loaded', function (done) {
|
||||
describe('#loadBubbles', function() {
|
||||
it('fires loadedImages when bubbles are loaded', function(done) {
|
||||
// adjust projection so that only one tile is fetched
|
||||
// (JSONP hack will return the same data for every fetch)
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(18))
|
||||
.translate([-1863988.9381333336, 762.8270222954452]) // 10.002,0.002
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
var spy = sinon.spy();
|
||||
streetside.on('loadedImages', spy);
|
||||
|
||||
window.JSONP_DELAY = 0;
|
||||
window.JSONP_FIX = [{
|
||||
elapsed: 0.001
|
||||
}, {
|
||||
id: 1, la: 0, lo: 10.001, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:00 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: undefined, ne: 2
|
||||
}, {
|
||||
id: 2, la: 0, lo: 10.002, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:01 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 1, ne: 3
|
||||
}, {
|
||||
id: 3, la: 0, lo: 10.003, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:02 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 2, ne: undefined
|
||||
}
|
||||
elapsed: 0.001
|
||||
}, {
|
||||
id: 1, la: 0, lo: 10.001, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:00 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: undefined, ne: 2
|
||||
}, {
|
||||
id: 2, la: 0, lo: 10.002, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:01 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 1, ne: 3
|
||||
}, {
|
||||
id: 3, la: 0, lo: 10.003, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:02 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 2, ne: undefined
|
||||
}
|
||||
];
|
||||
|
||||
streetside.loadBubbles(context.projection, 0); // 0 = don't fetch margin tiles
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
done();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
it('does not load bubbles around null island', function (done) {
|
||||
it('does not load bubbles around null island', function(done) {
|
||||
context.projection
|
||||
.scale(iD.geoZoomToScale(18))
|
||||
.translate([0, 0])
|
||||
.clipExtent([[0, 0], dimensions]);
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
var spy = sinon.spy();
|
||||
streetside.on('loadedImages', spy);
|
||||
|
||||
window.JSONP_DELAY = 0;
|
||||
window.JSONP_FIX = [{
|
||||
elapsed: 0.001
|
||||
}, {
|
||||
id: 1, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:00 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: undefined, ne: 2
|
||||
}, {
|
||||
id: 2, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:01 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 1, ne: 3
|
||||
}, {
|
||||
id: 3, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:02 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 2, ne: undefined
|
||||
}
|
||||
elapsed: 0.001
|
||||
}, {
|
||||
id: 1, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:00 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: undefined, ne: 2
|
||||
}, {
|
||||
id: 2, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:01 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 1, ne: 3
|
||||
}, {
|
||||
id: 3, la: 0, lo: 0, al: 0, ro: 0, pi: 0, he: 0, bl: '',
|
||||
cd: '1/1/2018 12:00:02 PM', ml: 3, nbn: [], pbn: [], rn: [],
|
||||
pr: 2, ne: undefined
|
||||
}
|
||||
];
|
||||
|
||||
streetside.loadBubbles(context.projection, 0); // 0 = don't fetch margin tiles
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(spy).to.have.been.not.called;
|
||||
done();
|
||||
}, 200);
|
||||
@@ -121,8 +121,8 @@ describe('iD.serviceStreetside', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#bubbles', function () {
|
||||
it('returns bubbles in the visible map area', function () {
|
||||
describe('#bubbles', function() {
|
||||
it('returns bubbles in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 1, loc: [10, 0], ca: 90, pr: undefined, ne: 2, pano: true, sequenceKey: 1 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 2, loc: [10, 0], ca: 90, pr: 1, ne: 3, pano: true, sequenceKey: 1 } },
|
||||
@@ -138,7 +138,7 @@ describe('iD.serviceStreetside', function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it('limits results no more than 5 stacked bubbles in one spot', function () {
|
||||
it('limits results no more than 5 stacked bubbles in one spot', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 1, loc: [10, 0], ca: 90, pr: undefined, ne: 2, pano: true, sequence_id: 1 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 2, loc: [10, 0], ca: 90, pr: 1, ne: 3, pano: true, sequence_id: 1 } },
|
||||
@@ -155,8 +155,8 @@ describe('iD.serviceStreetside', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('#sequences', function () {
|
||||
it('returns sequence linestrings in the visible map area', function () {
|
||||
describe('#sequences', function() {
|
||||
it('returns sequence linestrings in the visible map area', function() {
|
||||
var features = [
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 1, loc: [10, 0], ca: 90, pr: undefined, ne: 2, pano: true, sequenceKey: 1 } },
|
||||
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: 2, loc: [10, 0], ca: 90, pr: 1, ne: 3, pano: true, sequenceKey: 1 } },
|
||||
@@ -167,11 +167,11 @@ describe('iD.serviceStreetside', function () {
|
||||
|
||||
var seq = {
|
||||
key: 1,
|
||||
bubbles: features.map(function (f) { return f.data; }),
|
||||
bubbles: features.map(function(f) { return f.data; }),
|
||||
geojson: {
|
||||
type: 'LineString',
|
||||
properties: { key: 1 },
|
||||
coordinates: features.map(function (f) { return f.data.loc; }),
|
||||
coordinates: features.map(function(f) { return f.data.loc; }),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
describe('iD.serviceTaginfo', function () {
|
||||
describe('iD.serviceTaginfo', function() {
|
||||
var taginfo;
|
||||
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.services.taginfo = iD.serviceTaginfo;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.services.taginfo;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
taginfo = iD.services.taginfo;
|
||||
|
||||
fetchMock.mock(new RegExp('\/keys\/all.*sortname=values_all'), {
|
||||
@@ -24,7 +24,7 @@ describe('iD.serviceTaginfo', function () {
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
@@ -32,8 +32,8 @@ describe('iD.serviceTaginfo', function () {
|
||||
return iD.utilStringQs(url.substring(url.indexOf('?')));
|
||||
}
|
||||
|
||||
describe('#keys', function () {
|
||||
it('calls the given callback with the results of the keys query', function (done) {
|
||||
describe('#keys', function() {
|
||||
it('calls the given callback with the results of the keys query', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0}]}',
|
||||
status: 200,
|
||||
@@ -43,18 +43,18 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.keys({ query: 'amen' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ query: 'amen', page: '1', rp: '10', sortname: 'count_all', sortorder: 'desc', lang: 'en' }
|
||||
{query: 'amen', page: '1', rp: '10', sortname: 'count_all', sortorder: 'desc', lang: 'en'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'amenity', 'value': 'amenity' }]
|
||||
null, [{'title':'amenity', 'value':'amenity'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes popular keys', function (done) {
|
||||
it('includes popular keys', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":5190337,"count_nodes":500000,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
|
||||
+ '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes":100}]}',
|
||||
@@ -65,15 +65,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.keys({ query: 'amen' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'amenity', 'value': 'amenity' }]
|
||||
null, [{'title':'amenity', 'value':'amenity'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes popular keys with an entity type filter', function (done) {
|
||||
it('includes popular keys with an entity type filter', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":5190337,"count_nodes":500000,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
|
||||
+ '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes":100}]}',
|
||||
@@ -84,15 +84,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.keys({ query: 'amen', filter: 'nodes' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'amenity', 'value': 'amenity' }]
|
||||
null, [{'title':'amenity', 'value':'amenity'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes unpopular keys with a wiki page', function (done) {
|
||||
it('includes unpopular keys with a wiki page', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":5190337,"key":"amenity","count_all_fraction":1.0, "count_nodes_fraction":1.0},'
|
||||
+ '{"count_all":1,"key":"amenityother","count_all_fraction":0.0, "count_nodes_fraction":0.0, "in_wiki": true}]}',
|
||||
@@ -103,16 +103,16 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.keys({ query: 'amen' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(null, [
|
||||
{ 'title': 'amenity', 'value': 'amenity' },
|
||||
{ 'title': 'amenityother', 'value': 'amenityother' }
|
||||
{'title':'amenity', 'value':'amenity'},
|
||||
{'title':'amenityother', 'value':'amenityother'}
|
||||
]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('sorts keys with \':\' below keys without \':\'', function (done) {
|
||||
it('sorts keys with \':\' below keys without \':\'', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"key":"ref:bag","count_all":9790586,"count_all_fraction":0.0028},' +
|
||||
'{"key":"ref","count_all":7933528,"count_all_fraction":0.0023}]}',
|
||||
@@ -123,17 +123,17 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.keys({ query: 'ref' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'ref', 'value': 'ref' }, { 'title': 'ref:bag', 'value': 'ref:bag' }]
|
||||
null, [{'title':'ref', 'value':'ref'},{'title':'ref:bag', 'value':'ref:bag'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#multikeys', function () {
|
||||
it('calls the given callback with the results of the multikeys query', function (done) {
|
||||
describe('#multikeys', function() {
|
||||
it('calls the given callback with the results of the multikeys query', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":69593,"key":"recycling:glass","count_all_fraction":0.0}]}',
|
||||
status: 200,
|
||||
@@ -143,18 +143,18 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.multikeys({ query: 'recycling:' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ query: 'recycling:', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc', lang: 'en' }
|
||||
{query: 'recycling:', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc', lang: 'en'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'recycling:glass', 'value': 'recycling:glass' }]
|
||||
null, [{'title':'recycling:glass', 'value':'recycling:glass'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('excludes multikeys with extra colons', function (done) {
|
||||
it('excludes multikeys with extra colons', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":4426,"key":"service:bicycle:retail","count_all_fraction":0.0},' +
|
||||
'{"count_all":22,"key":"service:bicycle:retail:ebikes","count_all_fraction":0.0}]}',
|
||||
@@ -165,15 +165,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.multikeys({ query: 'service:bicycle:' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'service:bicycle:retail', 'value': 'service:bicycle:retail' }]
|
||||
null, [{'title':'service:bicycle:retail', 'value':'service:bicycle:retail'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('excludes multikeys with wrong prefix', function (done) {
|
||||
it('excludes multikeys with wrong prefix', function(done) {
|
||||
fetchMock.mock(/\/keys\/all/, {
|
||||
body: '{"data":[{"count_all":4426,"key":"service:bicycle:retail","count_all_fraction":0.0},' +
|
||||
'{"count_all":22,"key":"disused:service:bicycle","count_all_fraction":0.0}]}',
|
||||
@@ -184,17 +184,17 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.multikeys({ query: 'service:bicycle:' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'title': 'service:bicycle:retail', 'value': 'service:bicycle:retail' }]
|
||||
null, [{'title':'service:bicycle:retail', 'value':'service:bicycle:retail'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#values', function () {
|
||||
it('calls the given callback with the results of the values query', function (done) {
|
||||
describe('#values', function() {
|
||||
it('calls the given callback with the results of the values query', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.1}]}',
|
||||
status: 200,
|
||||
@@ -204,18 +204,18 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'amenity', query: 'par' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ key: 'amenity', query: 'par', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc', lang: 'en' }
|
||||
{key: 'amenity', query: 'par', page: '1', rp: '25', sortname: 'count_all', sortorder: 'desc', lang: 'en'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'parking', 'title': 'A place for parking cars' }]
|
||||
null, [{'value':'parking','title':'A place for parking cars'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes popular values', function (done) {
|
||||
it('includes popular values', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":1.0},' +
|
||||
'{"value":"party","description":"A place for partying", "fraction":0.0}]}',
|
||||
@@ -226,15 +226,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'amenity', query: 'par' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'parking', 'title': 'A place for parking cars' }]
|
||||
null, [{'value':'parking','title':'A place for parking cars'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('does not get values for extremely unpopular keys', function (done) {
|
||||
it('does not get values for extremely unpopular keys', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"Rue Pasteur","description":"", "fraction":0.0001},' +
|
||||
'{"value":"Via Trieste","description":"", "fraction":0.0001}]}',
|
||||
@@ -245,13 +245,13 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'name', query: 'ste' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(null, []);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('excludes values with capital letters and some punctuation', function (done) {
|
||||
it('excludes values with capital letters and some punctuation', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"parking","description":"A place for parking cars", "fraction":0.2},'
|
||||
+ '{"value":"PArking","description":"A common misspelling", "fraction":0.2},'
|
||||
@@ -265,15 +265,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'amenity', query: 'par' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'parking', 'title': 'A place for parking cars' }]
|
||||
null, [{'value':'parking','title':'A place for parking cars'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes network values with capital letters and some punctuation', function (done) {
|
||||
it('includes network values with capital letters and some punctuation', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"US:TX:FM","description":"Farm to Market Roads in the U.S. state of Texas.", "fraction":0.34},'
|
||||
+ '{"value":"US:KY","description":"Primary and secondary state highways in the U.S. state of Kentucky.", "fraction":0.31},'
|
||||
@@ -287,19 +287,19 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'network', query: 'us' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(null, [
|
||||
{ 'value': 'US:TX:FM', 'title': 'Farm to Market Roads in the U.S. state of Texas.' },
|
||||
{ 'value': 'US:KY', 'title': 'Primary and secondary state highways in the U.S. state of Kentucky.' },
|
||||
{ 'value': 'US:US', 'title': 'U.S. routes in the United States.' },
|
||||
{ 'value': 'US:I', 'title': 'Interstate highways in the United States.' },
|
||||
{ 'value': 'US:MD', 'title': 'State highways in the U.S. state of Maryland.' }
|
||||
{'value':'US:TX:FM','title':'Farm to Market Roads in the U.S. state of Texas.'},
|
||||
{'value':'US:KY','title':'Primary and secondary state highways in the U.S. state of Kentucky.'},
|
||||
{'value':'US:US','title':'U.S. routes in the United States.'},
|
||||
{'value':'US:I','title':'Interstate highways in the United States.'},
|
||||
{'value':'US:MD','title':'State highways in the U.S. state of Maryland.'}
|
||||
]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes biological genus values with capital letters', function (done) {
|
||||
it('includes biological genus values with capital letters', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"Quercus","description":"Oak", "fraction":0.5}]}',
|
||||
status: 200,
|
||||
@@ -309,15 +309,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'genus', query: 'qu' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'Quercus', 'title': 'Oak' }]
|
||||
null, [{'value':'Quercus','title':'Oak'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes biological taxon values with capital letters', function (done) {
|
||||
it('includes biological taxon values with capital letters', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}',
|
||||
status: 200,
|
||||
@@ -327,15 +327,15 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'taxon', query: 'qu' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'Quercus robur', 'title': 'Oak' }]
|
||||
null, [{'value':'Quercus robur','title':'Oak'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('includes biological species values with capital letters', function (done) {
|
||||
it('includes biological species values with capital letters', function(done) {
|
||||
fetchMock.mock(/\/key\/values/, {
|
||||
body: '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}',
|
||||
status: 200,
|
||||
@@ -345,17 +345,17 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({ key: 'species', query: 'qu' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'value': 'Quercus robur', 'title': 'Oak' }]
|
||||
null, [{'value':'Quercus robur','title':'Oak'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#roles', function () {
|
||||
it('calls the given callback with the results of the roles query', function (done) {
|
||||
describe('#roles', function() {
|
||||
it('calls the given callback with the results of the roles query', function(done) {
|
||||
fetchMock.mock(/\/relation\/roles/, {
|
||||
body: '{"data":[{"role":"stop","count_relation_members_fraction":0.1757},' +
|
||||
'{"role":"south","count_relation_members_fraction":0.0035}]}',
|
||||
@@ -366,21 +366,21 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.roles({ rtype: 'route', query: 's', geometry: 'relation' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ rtype: 'route', query: 's', page: '1', rp: '25', sortname: 'count_relation_members', sortorder: 'desc', lang: 'en' }
|
||||
{rtype: 'route', query: 's', page: '1', rp: '25', sortname: 'count_relation_members', sortorder: 'desc', lang: 'en'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWith(null, [
|
||||
{ 'value': 'stop', 'title': 'stop' },
|
||||
{ 'value': 'south', 'title': 'south' }
|
||||
{'value': 'stop', 'title': 'stop'},
|
||||
{'value': 'south', 'title': 'south'}
|
||||
]);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#docs', function () {
|
||||
it('calls the given callback with the results of the docs query', function (done) {
|
||||
describe('#docs', function() {
|
||||
it('calls the given callback with the results of the docs query', function(done) {
|
||||
fetchMock.mock(/\/tag\/wiki_page/, {
|
||||
body: '{"data":[{"on_way":false,"lang":"en","on_area":true,"image":"File:Car park2.jpg"}]}',
|
||||
status: 200,
|
||||
@@ -390,12 +390,12 @@ describe('iD.serviceTaginfo', function () {
|
||||
var callback = sinon.spy();
|
||||
taginfo.docs({ key: 'amenity', value: 'parking' }, callback);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(parseQueryString(fetchMock.calls()[0][0])).to.eql(
|
||||
{ key: 'amenity', value: 'parking' }
|
||||
{key: 'amenity', value: 'parking'}
|
||||
);
|
||||
expect(callback).to.have.been.calledWith(
|
||||
null, [{ 'on_way': false, 'lang': 'en', 'on_area': true, 'image': 'File:Car park2.jpg' }]
|
||||
null, [{'on_way':false,'lang':'en','on_area':true,'image':'File:Car park2.jpg'}]
|
||||
);
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
describe('iD.uiFieldWikipedia', function () {
|
||||
describe('iD.uiFieldWikipedia', function() {
|
||||
var entity, context, selection, field;
|
||||
|
||||
before(function () {
|
||||
before(function() {
|
||||
iD.fileFetcher.cache().wmf_sitematrix = [
|
||||
['German', 'Deutsch', 'de'],
|
||||
['English', 'English', 'en']
|
||||
['German','Deutsch','de'],
|
||||
['English','English','en']
|
||||
];
|
||||
iD.services.wikipedia = iD.serviceWikipedia;
|
||||
iD.services.wikidata = iD.serviceWikidata;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
after(function() {
|
||||
delete iD.fileFetcher.cache().wmf_sitematrix;
|
||||
delete iD.services.wikipedia;
|
||||
delete iD.services.wikidata;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
entity = iD.osmNode({ id: 'n12345' });
|
||||
beforeEach(function() {
|
||||
entity = iD.osmNode({id: 'n12345'});
|
||||
context = iD.coreContext().assetPath('../dist/').init();
|
||||
context.history().merge([entity]);
|
||||
selection = d3.select(document.createElement('div'));
|
||||
@@ -34,7 +34,7 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
@@ -60,11 +60,11 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
}
|
||||
}
|
||||
|
||||
it('recognizes lang:title format', function (done) {
|
||||
it('recognizes lang:title format', function(done) {
|
||||
var wikipedia = iD.uiFieldWikipedia(field, context);
|
||||
window.setTimeout(function () { // async, so data will be available
|
||||
window.setTimeout(function() { // async, so data will be available
|
||||
selection.call(wikipedia);
|
||||
wikipedia.tags({ wikipedia: 'en:Title' });
|
||||
wikipedia.tags({wikipedia: 'en:Title'});
|
||||
|
||||
expect(iD.utilGetSetValue(selection.selectAll('.wiki-lang'))).to.equal('English');
|
||||
expect(iD.utilGetSetValue(selection.selectAll('.wiki-title'))).to.equal('Title');
|
||||
@@ -72,9 +72,9 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
}, 20);
|
||||
});
|
||||
|
||||
it('sets language, value', function (done) {
|
||||
it('sets language, value', function(done) {
|
||||
var wikipedia = iD.uiFieldWikipedia(field, context).entityIDs([entity.id]);
|
||||
window.setTimeout(function () { // async, so data will be available
|
||||
window.setTimeout(function() { // async, so data will be available
|
||||
wikipedia.on('change', changeTags);
|
||||
selection.call(wikipedia);
|
||||
|
||||
@@ -90,17 +90,17 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
happen.once(selection.selectAll('.wiki-title').node(), { type: 'blur' });
|
||||
|
||||
expect(spy.callCount).to.equal(4);
|
||||
expect(spy.getCall(0)).to.have.been.calledWith({ wikipedia: undefined }); // lang on change
|
||||
expect(spy.getCall(1)).to.have.been.calledWith({ wikipedia: undefined }); // lang on blur
|
||||
expect(spy.getCall(0)).to.have.been.calledWith({ wikipedia: undefined}); // lang on change
|
||||
expect(spy.getCall(1)).to.have.been.calledWith({ wikipedia: undefined}); // lang on blur
|
||||
expect(spy.getCall(2)).to.have.been.calledWith({ wikipedia: 'de:Title' }); // title on change
|
||||
expect(spy.getCall(3)).to.have.been.calledWith({ wikipedia: 'de:Title' }); // title on blur
|
||||
done();
|
||||
}, 20);
|
||||
});
|
||||
|
||||
it('recognizes pasted URLs', function (done) {
|
||||
it('recognizes pasted URLs', function(done) {
|
||||
var wikipedia = iD.uiFieldWikipedia(field, context).entityIDs([entity.id]);
|
||||
window.setTimeout(function () { // async, so data will be available
|
||||
window.setTimeout(function() { // async, so data will be available
|
||||
wikipedia.on('change', changeTags);
|
||||
selection.call(wikipedia);
|
||||
|
||||
@@ -114,14 +114,14 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
});
|
||||
|
||||
// note - currently skipping the tests that use `options` to delay responses
|
||||
it('preserves existing language', function (done) {
|
||||
it('preserves existing language', function(done) {
|
||||
var wikipedia1 = iD.uiFieldWikipedia(field, context);
|
||||
window.setTimeout(function () { // async, so data will be available
|
||||
window.setTimeout(function() { // async, so data will be available
|
||||
selection.call(wikipedia1);
|
||||
iD.utilGetSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
|
||||
|
||||
var wikipedia2 = iD.uiFieldWikipedia(field, context);
|
||||
window.setTimeout(function () { // async, so data will be available
|
||||
window.setTimeout(function() { // async, so data will be available
|
||||
selection.call(wikipedia2);
|
||||
wikipedia2.tags({});
|
||||
expect(iD.utilGetSetValue(selection.selectAll('.wiki-lang'))).to.equal('Deutsch');
|
||||
@@ -130,7 +130,7 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
}, 20);
|
||||
});
|
||||
|
||||
it.skip('does not set delayed wikidata tag if graph has changed', function (done) {
|
||||
it.skip('does not set delayed wikidata tag if graph has changed', function(done) {
|
||||
var wikipedia = iD.uiFieldWikipedia(field, context).entityIDs([entity.id]);
|
||||
wikipedia.on('change', changeTags);
|
||||
selection.call(wikipedia);
|
||||
@@ -169,7 +169,7 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
});
|
||||
|
||||
// t30: graph change - Set title to "Title"
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
iD.utilGetSetValue(selection.selectAll('.wiki-title'), 'Title');
|
||||
happen.once(selection.selectAll('.wiki-title').node(), { type: 'change' });
|
||||
happen.once(selection.selectAll('.wiki-title').node(), { type: 'blur' });
|
||||
@@ -178,14 +178,14 @@ describe('iD.uiFieldWikipedia', function () {
|
||||
// t60: at t0 + 60ms (delay), wikidata SHOULD NOT be set because graph has changed.
|
||||
|
||||
// t70: check that wikidata unchanged
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.entity(entity.id).tags.wikidata).to.be.undefined;
|
||||
}, 70);
|
||||
|
||||
// t90: at t30 + 60ms (delay), wikidata SHOULD be set because graph is unchanged.
|
||||
|
||||
// t100: check that wikidata has changed
|
||||
window.setTimeout(function () {
|
||||
window.setTimeout(function() {
|
||||
expect(context.entity(entity.id).tags.wikidata).to.equal('Q216353');
|
||||
|
||||
expect(spy.callCount).to.equal(4);
|
||||
|
||||
Reference in New Issue
Block a user