Fix lib export, flatten names in tests and docs

This commit is contained in:
Bryan Housel
2016-10-04 21:55:50 -04:00
parent 0d0e54fdff
commit 87950fd472
81 changed files with 923 additions and 905 deletions
+5 -5
View File
@@ -96,7 +96,7 @@ have `.area` and `.way` classes.
Elements also receive classes according to certain of the OSM key-value tags that are
assigned to them.
Tag classes are prefixed with `tag-` (see [`iD.svg.TagClasses`](https://github.com/openstreetmap/iD/blob/master/js/id/svg/tag_classes.js) for details).
Tag classes are prefixed with `tag-` (see [`iD.svgTagClasses`](https://github.com/openstreetmap/iD/blob/master/js/id/svg/tag_classes.js) for details).
#### Primary
@@ -150,8 +150,8 @@ iD can use external presets exclusively or along with the default OpenStreetMap
var id = iD.Context(window)
.presets(customPresets)
.taginfo(iD.services.taginfo())
.imagery(iD.data.imagery);
.taginfo(iD.serviceTaginfo())
.imagery(iD.dataImagery);
```
@@ -165,7 +165,7 @@ Just like Presets, Imagery can be configured using the `context.imagery` accesso
var id = iD.Context(window)
.presets(customPresets)
.taginfo(iD.services.taginfo())
.taginfo(iD.serviceTaginfo())
.imagery(customImagery);
```
@@ -181,7 +181,7 @@ The Imagery object should follow the structure defined by [editor-layer-index](h
var id = iD.Context(window)
.presets(customPresets)
.taginfo(iD.services.taginfo().endpoint('url'))
.taginfo(iD.serviceTaginfo().endpoint('url'))
.imagery(customImagery);
```
+17 -17
View File
@@ -129,21 +129,21 @@ var tree = iD.Tree(graph);
// quickly pull all features that intersect with an extent
var features = tree.intersects(
iD.geo.Extent([0, 0], [2, 2]), tree.graph());
iD.geoExtent([0, 0], [2, 2]), tree.graph());
```
## Actions
In iD, an _action_ is a function that accepts a graph as input and returns a
new, modified graph as output. Actions typically need other inputs as well; for
example, `iD.actions.DeleteNode` also requires the ID of a node to delete. The
example, `iD.actionDeleteNode` also requires the ID of a node to delete. The
additional input is passed to the action's constructor:
```js
// construct the action: this returns a function that remembers the
// value `n123456` in a closure so that when it's called, it runs
// the specified action on the graph
var action = iD.actions.DeleteNode('n123456');
var action = iD.actionDeleteNode('n123456');
// apply the action, yielding a new graph. oldGraph is untouched.
newGraph = action(oldGraph);
@@ -184,10 +184,10 @@ around the map and select and edit entities, and three geometrically-oriented
drawing modes, which are accessible through the mode buttons in the upper
toolbar: Point, Line, and Area. In the code, these are broken down a
little bit more. There are separate modes for when an entity is selected
(`iD.modes.Select`) versus when nothing is selected (`iD.modes.Browse`), and
(`iD.modeSelect`) versus when nothing is selected (`iD.modeBrowse`), and
each of the geometric modes is split into one mode for starting to draw an
object and one mode for continuing an existing object (with the exception of
`iD.modes.AddPoint`, which is a single-step operation for obvious reasons).
`iD.modeAddPoint`, which is a single-step operation for obvious reasons).
The code interface for each mode consists of a pair of methods: `enter` and
`exit`. In the `enter` method, a mode sets up all the behavior that should be
@@ -205,7 +205,7 @@ Certain behaviors are common to more than one mode. For example, iD indicates
interactive map elements by drawing a halo around them when you hover over
them, and this behavior is common to both the browse and draw modes. Instead
of duplicating the code to implement this behavior in all these modes, we
extract it to `iD.behavior.Hover`.
extract it to `iD.behaviorHover`.
_Behaviors_ take their inspiration from [d3's
behaviors](https://github.com/mbostock/d3/wiki/Behaviors). Like d3's `zoom`
@@ -247,8 +247,8 @@ conditions under which it is enabled.
To execute an operation, call it as a function, with no arguments. The typical
operation will perform the appropriate action, creating a new undo state in
the history, and then enter the appropriate mode. For example,
`iD.operations.Split` performs `iD.actions.Split`, then enters
`iD.modes.Select` with the resulting ways selected.
`iD.operationSplit` performs `iD.actionSplit`, then enters
`iD.modeSelect` with the resulting ways selected.
## Map Rendering
@@ -270,7 +270,7 @@ entity types of the OSM data model:
or more ways grouped in a multipolygon relation.
For each of these geometric types, `iD.svg` has a corresponding module:
`iD.svg.Points`, `iD.svg.Vertices`, `iD.svg.Lines`, and `iD.svg.Areas`. To
`iD.svgPoints`, `iD.svgVertices`, `iD.svgLines`, and `iD.svgAreas`. To
render entities on screen, `iD.Map` delegates to these modules. Internally,
they make heavy use of [d3 joins](http://bost.ocks.org/mike/join/) to
manipulate the SVG elements that visually represent the map entities. When an
@@ -282,7 +282,7 @@ are updated. And when an entity is deleted (or simply moves offscreen), the
corresponding SVG element is in the _exit_ selection, and will be removed.
The `iD.svg` modules apply classes to the SVG elements based on the entity
tags, via `iD.svg.TagClasses`. For example, an entity tagged with
tags, via `iD.svgTagClasses`. For example, an entity tagged with
`highway=residential` gets two classes: `tag-highway` and
`tag-highway-residential`. This allows distinct visual styles to be applied
via CSS at either the key or key-value levels. SVG elements also receive a
@@ -292,11 +292,11 @@ one corresponding to their geometry type (`point`, `line`, or `area`).
The `iD.svg` namespace has a few other modules that don't have a one-to-one
correspondence with entities:
* `iD.svg.Midpoints` renders the small "virtual node" at the midpoint between
* `iD.svgMidpoints` renders the small "virtual node" at the midpoint between
two vertices.
* `iD.svg.Labels` renders the textual
* `iD.svgLabels` renders the textual
[labels](http://mapbox.com/osmdev/2013/02/12/labeling-id/).
* `iD.svg.Layers` sets up a number of layers that ensure that map elements
* `iD.svgLayers` sets up a number of layers that ensure that map elements
appear in an appropriate z-order.
## Other UI
@@ -312,7 +312,7 @@ The implementations for all non-map UI components live in the `iD.ui` namespace.
Many of the modules in this namespace follow a pattern for reusable d3
components [originally suggested](http://bost.ocks.org/mike/chart/) by Mike
Bostock in the context of charts. The entry point to a UI element is a
constructor function, e.g. `iD.ui.Geocoder()`. The constructor function may
constructor function, e.g. `iD.uiGeocoder()`. The constructor function may
require a set of mandatory arguments; for most UI components exactly one
argument is required, a `context` object produced by the top-level `iD()`
function.
@@ -326,7 +326,7 @@ render itself:
var container = d3.select('body').append('div')
.attr('class', 'map-control geocode-control');
var geocoder = iD.ui.Geocoder(context)(container);
var geocoder = iD.uiGeocoder(context)(container);
```
Alternatively, and more commonly, the same result is accomplished with
@@ -335,7 +335,7 @@ Alternatively, and more commonly, the same result is accomplished with
```
d3.select('body').append('div')
.attr('class', 'map-control geocode-control')
.call(iD.ui.Geocoder(context));
.call(iD.uiGeocoder(context));
```
Some components are reconfigurable, and some provide functionality beyond
@@ -343,7 +343,7 @@ basic rendering. Both reconfiguration and extended functionality are exposed
via module functions:
```
var inspector = iD.ui.Inspector();
var inspector = iD.uiInspector();
inspector(container); // render the inspector
inspector.tags(); // retrieve the current tags
inspector.on('change', callback); // get notified when a tag change is made
+1 -1
View File
@@ -124,7 +124,7 @@
* Add ability to remove/disable Mapillary layers (#2722)
* Add expansion arrows to category presets for better usability (#2972, thanks @kepta)
* Refactor services into iD.services namespace
* :warning: This means that `iD.taginfo` is now `iD.services.taginfo`
* :warning: This means that `iD.taginfo` is now `iD.serviceTaginfo`
* Disallow disconnecting that would damage relations (#1714, thanks @jfirebaugh)
* Allow escape to cancel ⌘-V paste (#2889)
* Enter should accept input and return to browse mode only on preset input fields (#2912, #2957, #2380)
+1 -1
View File
@@ -75,7 +75,7 @@ reverting to the previous version.
The persistent data structure approach also takes advantage of the fact that the typical change modifies
only a small portion of the graph. The unchanged majority of the graph is shared between revisions,
keeping memory use to a minimum. For example, the `iD.actions.RemoveWayNode` action removes a single
keeping memory use to a minimum. For example, the `iD.actionRemoveWayNode` action removes a single
node from a way. It produces new versions of three objects:
* The Array of nodes in the way.
+4 -4
View File
@@ -18,16 +18,16 @@
<div id='id-container'></div>
<script>
id = iD.Context(window)
.presets(iD.data.presets)
.imagery(iD.data.imagery)
.taginfo(iD.services.taginfo.init())
.presets(iD.dataPresets)
.imagery(iD.dataImagery)
.taginfo(iD.serviceTaginfo.init())
.assetPath('dist/');
id.ui()(document.getElementById('id-container'));
iD.d3.select('#about-list').insert('li', '.user-list')
.attr('class', 'source-switch')
.call(iD.ui.SourceSwitch(id)
.call(iD.uiSourceSwitch(id)
.keys([
{
'url': 'http://www.openstreetmap.org',
+1 -1
View File
@@ -135,7 +135,7 @@ export function actionCircularize(wayId, projection, maxAngle) {
insertAt = startIndex2;
}
for (j = 0; j < inBetweenNodes.length; j++) {
sharedWay = sharedWay.addcoreNode(inBetweenNodes[j], insertAt + j);
sharedWay = sharedWay.addNode(inBetweenNodes[j], insertAt + j);
}
graph = graph.replace(sharedWay);
}
+5 -1
View File
@@ -9,6 +9,8 @@ export * from './presets/index';
export * from './renderer/index';
export * from './services/index';
export * from './svg/index';
export * from './ui/fields/index';
export * from './ui/intro/index';
export * from './ui/index';
export * from './util/index';
export * from './lib/index';
@@ -35,4 +37,6 @@ export { utilDetect as Detect } from './util/detect';
export var debug = false;
import * as d3 from 'd3';
export { d3 };
import * as lib from './lib/index';
export { d3, lib };
+14
View File
@@ -1,3 +1,17 @@
export * from './check';
export * from './combo';
export * from './input';
export * from './access';
export * from './address';
export * from './cycleway';
export * from './lanes';
export * from './localized';
export * from './maxspeed';
export * from './radio';
export * from './restrictions';
export * from './textarea';
export * from './wikipedia';
import {
uiFieldCheck,
uiFieldDefaultcheck
+14 -14
View File
@@ -35,7 +35,7 @@
.style('background-color', d3.rgb(v,v,v));
});
var infiniteExtent = iD.geo.Extent([0, 0], [Infinity, Infinity]),
var infiniteExtent = iD.geoExtent([0, 0], [Infinity, Infinity]),
projection = function(p) { return p; },
filter = function() { return true; },
context = {};
@@ -45,7 +45,7 @@
};
context.presets = function() {
return iD.presets.presets().load({
return iD.presetInit().load({
presets: {
'amenity/restaurant': {
geometry: ['point'],
@@ -109,7 +109,7 @@
var data = [{}, {amenity: 'restaurant'}],
modes = ['base', 'hover', 'selected'],
node = iD.Node({loc: [15, 30]}),
points = iD.svg.Points(projection, context);
points = iD.svgPoints(projection, context);
var row = d3.select('.points').selectAll('tr')
.data(data)
@@ -131,7 +131,7 @@
.attr('width', 30)
.attr('height', 40)
.attr('data-zoom', function (d) { return d.zoom; })
.call(iD.svg.Layers(projection, context))
.call(iD.svgLayers(projection, context))
.each(function (d) {
var n = node.update({tags: d}),
graph = iD.Graph([n]);
@@ -175,7 +175,7 @@
modes = ['base', 'hover', 'selected'],
node = iD.Node({loc: [15, 15]}),
way = iD.Way({nodes: [node.id]}),
vertices = iD.svg.Vertices(projection, context);
vertices = iD.svgVertices(projection, context);
var row = d3.select('.vertices').selectAll('tr')
.data(data)
@@ -199,7 +199,7 @@
.attr('width', 30)
.attr('height', 30)
.attr('data-zoom', function (d) { return d.zoom; })
.call(iD.svg.Layers(projection, context))
.call(iD.svgLayers(projection, context))
.each(function (d) {
var n = node.update({tags: d.tags}),
graph = iD.Graph([n, way]);
@@ -268,9 +268,9 @@
var a = iD.Node({loc: [15, 15]}),
b = iD.Node({loc: [185, 15]}),
way = iD.Way({nodes: [a.id, b.id]}),
vertices = iD.svg.Vertices(projection, context),
lines = iD.svg.Lines(projection, context),
midpoints = iD.svg.Midpoints(projection, context);
vertices = iD.svgVertices(projection, context),
lines = iD.svgLines(projection, context),
midpoints = iD.svgMidpoints(projection, context);
row.selectAll('td')
.data(function (d) {
@@ -287,7 +287,7 @@
.attr('width', 200)
.attr('height', 30)
.attr('data-zoom', function (d) { return d.zoom; })
.call(iD.svg.Layers(projection, context))
.call(iD.svgLayers(projection, context))
.each(function (d) {
var highway = way.update({tags: d.tags}),
graph = iD.Graph([a, b, highway]);
@@ -334,9 +334,9 @@
c = iD.Node({loc: [85, 85]}),
d = iD.Node({loc: [15, 85]}),
way = iD.Way({nodes: [a.id, b.id, c.id, d.id, a.id]}),
vertices = iD.svg.Vertices(projection, context),
areas = iD.svg.Areas(projection, context),
midpoints = iD.svg.Midpoints(projection, context);
vertices = iD.svgVertices(projection, context),
areas = iD.svgAreas(projection, context),
midpoints = iD.svgMidpoints(projection, context);
row.selectAll('td')
.data(function (d) {
@@ -349,7 +349,7 @@
.append('svg')
.attr('width', 100)
.attr('height', 100)
.call(iD.svg.Layers(projection, context))
.call(iD.svgLayers(projection, context))
.each(function (datum) {
var area = way.update({tags: datum.tags}),
graph = iD.Graph([a, b, c, d, area]);
+2 -2
View File
@@ -1,7 +1,7 @@
describe('iD.actions.AddEntity', function () {
describe('iD.actionAddEntity', function () {
it('adds an entity to the graph', function () {
var entity = iD.Entity(),
graph = iD.actions.AddEntity(entity)(iD.Graph());
graph = iD.actionAddEntity(entity)(iD.Graph());
expect(graph.entity(entity.id)).to.equal(entity);
});
});
+7 -7
View File
@@ -1,7 +1,7 @@
describe('iD.actions.AddMember', function() {
describe('iD.actionAddMember', function() {
it('adds an member to a relation at the specified index', function() {
var r = iD.Relation({members: [{id: '1'}, {id: '3'}]}),
g = iD.actions.AddMember(r.id, {id: '2'}, 1)(iD.Graph([r]));
g = iD.actionAddMember(r.id, {id: '2'}, 1)(iD.Graph([r]));
expect(g.entity(r.id).members).to.eql([{id: '1'}, {id: '2'}, {id: '3'}]);
});
@@ -18,7 +18,7 @@ describe('iD.actions.AddMember', function() {
iD.Relation({id: 'r'})
]);
graph = iD.actions.AddMember('r', {id: '-', type: 'way'})(graph);
graph = iD.actionAddMember('r', {id: '-', type: 'way'})(graph);
expect(members(graph)).to.eql(['-']);
});
@@ -34,7 +34,7 @@ describe('iD.actions.AddMember', function() {
iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]})
]);
graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph);
graph = iD.actionAddMember('r', {id: '=', type: 'way'})(graph);
expect(members(graph)).to.eql(['-', '=']);
});
@@ -49,7 +49,7 @@ describe('iD.actions.AddMember', function() {
iD.Relation({id: 'r', members: [{id: '-', type: 'way'}]})
]);
graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph);
graph = iD.actionAddMember('r', {id: '=', type: 'way'})(graph);
expect(members(graph)).to.eql(['-', '=']);
});
@@ -66,7 +66,7 @@ describe('iD.actions.AddMember', function() {
iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]})
]);
graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph);
graph = iD.actionAddMember('r', {id: '=', type: 'way'})(graph);
expect(members(graph)).to.eql(['=', '-', '~']);
});
@@ -83,7 +83,7 @@ describe('iD.actions.AddMember', function() {
iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]})
]);
graph = iD.actions.AddMember('r', {id: '=', type: 'way'})(graph);
graph = iD.actionAddMember('r', {id: '=', type: 'way'})(graph);
expect(members(graph)).to.eql(['-', '=', '~']);
});
});
+5 -5
View File
@@ -1,10 +1,10 @@
describe('iD.actions.AddMidpoint', function () {
describe('iD.actionAddMidpoint', function () {
it('adds the node at the midpoint location', function () {
var node = iD.Node(),
a = iD.Node(),
b = iD.Node(),
midpoint = {loc: [1, 2], edge: [a.id, b.id]},
graph = iD.actions.AddMidpoint(midpoint, node)(iD.Graph([a, b]));
graph = iD.actionAddMidpoint(midpoint, node)(iD.Graph([a, b]));
expect(graph.entity(node.id).loc).to.eql([1, 2]);
});
@@ -16,7 +16,7 @@ describe('iD.actions.AddMidpoint', function () {
w1 = iD.Way(),
w2 = iD.Way({nodes: [a.id, b.id]}),
midpoint = {loc: [1, 2], edge: [a.id, b.id]},
graph = iD.actions.AddMidpoint(midpoint, node)(iD.Graph([a, b, w1, w2]));
graph = iD.actionAddMidpoint(midpoint, node)(iD.Graph([a, b, w1, w2]));
expect(graph.entity(w1.id).nodes).to.eql([]);
expect(graph.entity(w2.id).nodes).to.eql([a.id, node.id, b.id]);
@@ -29,7 +29,7 @@ describe('iD.actions.AddMidpoint', function () {
w1 = iD.Way(),
w2 = iD.Way({nodes: [b.id, a.id]}),
midpoint = {loc: [1, 2], edge: [a.id, b.id]},
graph = iD.actions.AddMidpoint(midpoint, node)(iD.Graph([a, b, w1, w2]));
graph = iD.actionAddMidpoint(midpoint, node)(iD.Graph([a, b, w1, w2]));
expect(graph.entity(w1.id).nodes).to.eql([]);
expect(graph.entity(w2.id).nodes).to.eql([b.id, node.id, a.id]);
@@ -47,7 +47,7 @@ describe('iD.actions.AddMidpoint', function () {
c = iD.Node(),
w = iD.Way({nodes: [a.id, b.id, a.id]}),
midpoint = {loc: [1, 2], edge: [a.id, b.id]},
graph = iD.actions.AddMidpoint(midpoint, c)(iD.Graph([a, b, w]));
graph = iD.actionAddMidpoint(midpoint, c)(iD.Graph([a, b, w]));
expect(graph.entity(w.id).nodes).to.eql([a.id, c.id, b.id, a.id]);
});
+2 -2
View File
@@ -1,8 +1,8 @@
describe('iD.actions.ChangeMember', function () {
describe('iD.actionChangeMember', function () {
it('updates the member at the specified index', function () {
var node = iD.Node(),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.ChangeMember(relation.id, {id: node.id, role: 'node'}, 0),
action = iD.actionChangeMember(relation.id, {id: node.id, role: 'node'}, 0),
graph = action(iD.Graph([node, relation]));
expect(graph.entity(relation.id).members).to.eql([{id: node.id, role: 'node'}]);
});
+6 -6
View File
@@ -1,25 +1,25 @@
describe('iD.actions.ChangePreset', function() {
var oldPreset = iD.presets.Preset('old', {tags: {old: 'true'}}),
newPreset = iD.presets.Preset('new', {tags: {new: 'true'}});
describe('iD.actionChangePreset', function() {
var oldPreset = iD.presetPreset('old', {tags: {old: 'true'}}),
newPreset = iD.presetPreset('new', {tags: {new: 'true'}});
it('changes from one preset\'s tags to another\'s', function() {
var entity = iD.Node({tags: {old: 'true'}}),
graph = iD.Graph([entity]),
action = iD.actions.ChangePreset(entity.id, oldPreset, newPreset);
action = iD.actionChangePreset(entity.id, oldPreset, newPreset);
expect(action(graph).entity(entity.id).tags).to.eql({new: 'true'});
});
it('adds the tags of a new preset to an entity without an old preset', function() {
var entity = iD.Node(),
graph = iD.Graph([entity]),
action = iD.actions.ChangePreset(entity.id, null, newPreset);
action = iD.actionChangePreset(entity.id, null, newPreset);
expect(action(graph).entity(entity.id).tags).to.eql({new: 'true'});
});
it('removes the tags of an old preset from an entity without a new preset', function() {
var entity = iD.Node({tags: {old: 'true'}}),
graph = iD.Graph([entity]),
action = iD.actions.ChangePreset(entity.id, oldPreset, null);
action = iD.actionChangePreset(entity.id, oldPreset, null);
expect(action(graph).entity(entity.id).tags).to.eql({});
});
});
+2 -2
View File
@@ -1,8 +1,8 @@
describe('iD.actions.ChangeTags', function () {
describe('iD.actionChangeTags', function () {
it('changes an entity\'s tags', function () {
var entity = iD.Entity(),
tags = {foo: 'bar'},
graph = iD.actions.ChangeTags(entity.id, tags)(iD.Graph([entity]));
graph = iD.actionChangeTags(entity.id, tags)(iD.Graph([entity]));
expect(graph.entity(entity.id).tags).to.eql(tags);
});
});
+15 -15
View File
@@ -1,10 +1,10 @@
describe('iD.actions.Circularize', function () {
describe('iD.actionCircularize', function () {
var projection = d3.geoMercator().scale(150);
function isCircular(id, graph) {
var points = _.map(graph.childNodes(graph.entity(id)), 'loc').map(projection),
centroid = d3.polygonCentroid(points),
radius = iD.geo.euclideanDistance(centroid, points[0]),
radius = iD.geoEuclideanDistance(centroid, points[0]),
estArea = Math.PI * radius * radius,
trueArea = Math.abs(d3.polygonArea(points)),
pctDiff = (estArea - trueArea) / estArea;
@@ -24,7 +24,7 @@ describe('iD.actions.Circularize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
]);
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(graph.entity('-').nodes).to.have.length(20);
@@ -44,7 +44,7 @@ describe('iD.actions.Circularize', function () {
]),
nodes;
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
@@ -69,10 +69,10 @@ describe('iD.actions.Circularize', function () {
iD.Way({id: '=', nodes: ['d']})
]);
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(iD.geo.euclideanDistance(graph.entity('d').loc, [2, -2])).to.be.lt(0.5);
expect(iD.geoEuclideanDistance(graph.entity('d').loc, [2, -2])).to.be.lt(0.5);
});
function angle(point1, point2, center) {
@@ -80,10 +80,10 @@ describe('iD.actions.Circularize', function () {
vector2 = [point2[0] - center[0], point2[1] - center[1]],
distance;
distance = iD.geo.euclideanDistance(vector1, [0, 0]);
distance = iD.geoEuclideanDistance(vector1, [0, 0]);
vector1 = [vector1[0] / distance, vector1[1] / distance];
distance = iD.geo.euclideanDistance(vector2, [0, 0]);
distance = iD.geoEuclideanDistance(vector2, [0, 0]);
vector2 = [vector2[0] / distance, vector2[1] / distance];
return 180 / Math.PI * Math.acos(vector1[0] * vector2[0] + vector1[1] * vector2[1]);
@@ -102,7 +102,7 @@ describe('iD.actions.Circularize', function () {
]),
centroid, points;
graph = iD.actions.Circularize('-', projection, 20)(graph);
graph = iD.actionCircularize('-', projection, 20)(graph);
expect(isCircular('-', graph)).to.be.ok;
points = _.map(graph.childNodes(graph.entity('-')), 'loc').map(projection);
@@ -133,7 +133,7 @@ describe('iD.actions.Circularize', function () {
expect(area('+', graph)).to.be.gt(0);
graph = iD.actions.Circularize('+', projection)(graph);
graph = iD.actionCircularize('+', projection)(graph);
expect(isCircular('+', graph)).to.be.ok;
expect(area('+', graph)).to.be.gt(0);
@@ -153,7 +153,7 @@ describe('iD.actions.Circularize', function () {
expect(area('-', graph)).to.be.lt(0);
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(area('-', graph)).to.be.lt(0);
@@ -185,7 +185,7 @@ describe('iD.actions.Circularize', function () {
expect(graph.entity('-').isConvex(graph)).to.be.false;
expect(graph.entity('=').isConvex(graph)).to.be.true;
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(_.intersection(graph.entity('-').nodes, graph.entity('=').nodes).length).to.be.gt(3);
@@ -219,7 +219,7 @@ describe('iD.actions.Circularize', function () {
expect(graph.entity('-').isConvex(graph)).to.be.false;
expect(graph.entity('=').isConvex(graph)).to.be.true;
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(_.intersection(graph.entity('-').nodes, graph.entity('=').nodes).length).to.be.gt(3);
@@ -250,7 +250,7 @@ describe('iD.actions.Circularize', function () {
expect(graph.entity('-').isConvex(graph)).to.be.false;
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
expect(graph.entity('-').isConvex(graph)).to.be.true;
@@ -266,7 +266,7 @@ describe('iD.actions.Circularize', function () {
expect(area('-', graph)).to.eql(0);
graph = iD.actions.Circularize('-', projection)(graph);
graph = iD.actionCircularize('-', projection)(graph);
expect(isCircular('-', graph)).to.be.ok;
});
+9 -9
View File
@@ -1,4 +1,4 @@
describe('iD.actions.Connect', function() {
describe('iD.actionConnect', function() {
it('removes all but the final node', function() {
var graph = iD.Graph([
iD.Node({id: 'a'}),
@@ -6,7 +6,7 @@ describe('iD.actions.Connect', function() {
iD.Node({id: 'c'})
]);
graph = iD.actions.Connect(['a', 'b', 'c'])(graph);
graph = iD.actionConnect(['a', 'b', 'c'])(graph);
expect(graph.hasEntity('a')).to.be.undefined;
expect(graph.hasEntity('b')).to.be.undefined;
@@ -38,7 +38,7 @@ describe('iD.actions.Connect', function() {
iD.Way({id: '|', nodes: ['d', 'e']})
]);
graph = iD.actions.Connect(['e', 'b'])(graph);
graph = iD.actionConnect(['e', 'b'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
expect(graph.entity('|').nodes).to.eql(['d', 'b']);
@@ -63,7 +63,7 @@ describe('iD.actions.Connect', function() {
iD.Way({id: '=', nodes: ['d', 'e']})
]);
graph = iD.actions.Connect(['a', 'd'])(graph);
graph = iD.actionConnect(['a', 'd'])(graph);
expect(graph.entity('-').nodes).to.eql(['d', 'b', 'c', 'd']);
});
@@ -84,7 +84,7 @@ describe('iD.actions.Connect', function() {
iD.Way({id: '-', nodes: ['a', 'b', 'c']})
]);
graph = iD.actions.Connect(['b', 'c'])(graph);
graph = iD.actionConnect(['b', 'c'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'c']);
expect(graph.hasEntity('b')).to.be.undefined;
@@ -112,7 +112,7 @@ describe('iD.actions.Connect', function() {
iD.Way({id: '|', nodes: ['b', 'd']})
]);
graph = iD.actions.Connect(['b', 'c'])(graph);
graph = iD.actionConnect(['b', 'c'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'c']);
expect(graph.entity('|').nodes).to.eql(['c', 'd']);
@@ -130,7 +130,7 @@ describe('iD.actions.Connect', function() {
iD.Way({id: '-', nodes: ['a', 'b']})
]);
graph = iD.actions.Connect(['a', 'b'])(graph);
graph = iD.actionConnect(['a', 'b'])(graph);
expect(graph.hasEntity('a')).to.be.undefined;
expect(graph.hasEntity('-')).to.be.undefined;
@@ -143,7 +143,7 @@ describe('iD.actions.Connect', function() {
iD.Node({id: 'c', tags: {c: 'c'}})
]);
graph = iD.actions.Connect(['a', 'b', 'c'])(graph);
graph = iD.actionConnect(['a', 'b', 'c'])(graph);
expect(graph.entity('c').tags).to.eql({a: 'a', b: 'b', c: 'c'});
});
@@ -160,7 +160,7 @@ describe('iD.actions.Connect', function() {
iD.Relation({id: 'r2', members: [{id: 'b', role: 'r2', type: 'node'}, {id: 'c', role: 'r2', type: 'node'}]})
]);
graph = iD.actions.Connect(['b', 'c'])(graph);
graph = iD.actionConnect(['b', 'c'])(graph);
expect(graph.entity('r1').members).to.eql([{id: 'c', role: 'r1', type: 'node'}]);
expect(graph.entity('r2').members).to.eql([{id: 'c', role: 'r2', type: 'node'}]);
+6 -6
View File
@@ -1,8 +1,8 @@
describe('iD.actions.CopyEntities', function () {
describe('iD.actionCopyEntities', function () {
it('copies a node', function () {
var a = iD.Node({id: 'a'}),
base = iD.Graph([a]),
head = iD.actions.CopyEntities(['a'], base)(base),
head = iD.actionCopyEntities(['a'], base)(base),
diff = iD.Difference(base, head),
created = diff.created();
@@ -15,7 +15,7 @@ describe('iD.actions.CopyEntities', function () {
b = iD.Node({id: 'b'}),
w = iD.Way({id: 'w', nodes: ['a', 'b']}),
base = iD.Graph([a, b, w]),
action = iD.actions.CopyEntities(['w'], base),
action = iD.actionCopyEntities(['w'], base),
head = action(base),
diff = iD.Difference(base, head),
created = diff.created();
@@ -29,7 +29,7 @@ describe('iD.actions.CopyEntities', function () {
iD.Node({id: 'a'}),
iD.Node({id: 'b'})
]),
action = iD.actions.CopyEntities(['a', 'b'], base),
action = iD.actionCopyEntities(['a', 'b'], base),
head = action(base),
diff = iD.Difference(base, head),
created = diff.created();
@@ -47,7 +47,7 @@ describe('iD.actions.CopyEntities', function () {
iD.Way({id: 'w1', nodes: ['a', 'b']}),
iD.Way({id: 'w2', nodes: ['b', 'c']})
]),
action = iD.actions.CopyEntities(['w1', 'w2'], base),
action = iD.actionCopyEntities(['w1', 'w2'], base),
head = action(base),
diff = iD.Difference(base, head),
created = diff.created();
@@ -60,7 +60,7 @@ describe('iD.actions.CopyEntities', function () {
var a = iD.Node({id: 'a'}),
old = iD.Graph([a]),
base = iD.Graph(),
action = iD.actions.CopyEntities(['a'], old),
action = iD.actionCopyEntities(['a'], old),
head = action(base),
diff = iD.Difference(base, head);
diff.created();
+3 -3
View File
@@ -1,9 +1,9 @@
describe('iD.actions.DeleteMember', function () {
describe('iD.actionDeleteMember', function () {
it('removes the member at the specified index', function () {
var a = iD.Node({id: 'a'}),
b = iD.Node({id: 'b'}),
r = iD.Relation({members: [{id: 'a'}, {id: 'b'}]}),
action = iD.actions.DeleteMember(r.id, 0),
action = iD.actionDeleteMember(r.id, 0),
graph = action(iD.Graph([a, b, r]));
expect(graph.entity(r.id).members).to.eql([{id: 'b'}]);
});
@@ -11,7 +11,7 @@ describe('iD.actions.DeleteMember', function () {
it('deletes relations that become degenerate', function () {
var a = iD.Node({id: 'a'}),
r = iD.Relation({id: 'r', members: [{id: 'a'}]}),
action = iD.actions.DeleteMember(r.id, 0),
action = iD.actionDeleteMember(r.id, 0),
graph = action(iD.Graph([a, r]));
expect(graph.hasEntity('r')).to.be.undefined;
});
+4 -4
View File
@@ -1,9 +1,9 @@
describe('iD.actions.DeleteMultiple', function () {
describe('iD.actionDeleteMultiple', function () {
it('deletes multiple entities of heterogeneous types', function () {
var n = iD.Node(),
w = iD.Way(),
r = iD.Relation(),
action = iD.actions.DeleteMultiple([n.id, w.id, r.id]),
action = iD.actionDeleteMultiple([n.id, w.id, r.id]),
graph = action(iD.Graph([n, w, r]));
expect(graph.hasEntity(n.id)).to.be.undefined;
expect(graph.hasEntity(w.id)).to.be.undefined;
@@ -13,7 +13,7 @@ describe('iD.actions.DeleteMultiple', function () {
it('deletes a way and one of its nodes', function () {
var n = iD.Node(),
w = iD.Way({nodes: [n.id]}),
action = iD.actions.DeleteMultiple([w.id, n.id]),
action = iD.actionDeleteMultiple([w.id, n.id]),
graph = action(iD.Graph([n, w]));
expect(graph.hasEntity(w.id)).to.be.undefined;
expect(graph.hasEntity(n.id)).to.be.undefined;
@@ -24,7 +24,7 @@ describe('iD.actions.DeleteMultiple', function () {
var node = iD.Node(),
relation = iD.Relation({members: [{id: 'w'}]}),
graph = iD.Graph([node, relation]),
action = iD.actions.DeleteMultiple([node.id, relation.id]);
action = iD.actionDeleteMultiple([node.id, relation.id]);
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
});
+7 -7
View File
@@ -1,7 +1,7 @@
describe('iD.actions.DeleteNode', function () {
describe('iD.actionDeleteNode', function () {
it('removes the node from the graph', function () {
var node = iD.Node(),
action = iD.actions.DeleteNode(node.id),
action = iD.actionDeleteNode(node.id),
graph = action(iD.Graph([node]));
expect(graph.hasEntity(node.id)).to.be.undefined;
});
@@ -11,7 +11,7 @@ describe('iD.actions.DeleteNode', function () {
node2 = iD.Node(),
node3 = iD.Node(),
way = iD.Way({nodes: [node1.id, node2.id, node3.id]}),
action = iD.actions.DeleteNode(node1.id),
action = iD.actionDeleteNode(node1.id),
graph = action(iD.Graph([node1, node2, node3, way]));
expect(graph.entity(way.id).nodes).to.eql([node2.id, node3.id]);
});
@@ -20,7 +20,7 @@ describe('iD.actions.DeleteNode', function () {
var node1 = iD.Node(),
node2 = iD.Node(),
relation = iD.Relation({members: [{ id: node1.id }, { id: node2.id }]}),
action = iD.actions.DeleteNode(node1.id),
action = iD.actionDeleteNode(node1.id),
graph = action(iD.Graph([node1, node2, relation]));
expect(graph.entity(relation.id).members).to.eql([{ id: node2.id }]);
});
@@ -29,7 +29,7 @@ describe('iD.actions.DeleteNode', function () {
var node1 = iD.Node(),
node2 = iD.Node(),
way = iD.Way({nodes: [node1.id, node2.id]}),
action = iD.actions.DeleteNode(node1.id),
action = iD.actionDeleteNode(node1.id),
graph = action(iD.Graph([node1, node2, way]));
expect(graph.hasEntity(way.id)).to.be.undefined;
});
@@ -38,7 +38,7 @@ describe('iD.actions.DeleteNode', function () {
var node1 = iD.Node(),
node2 = iD.Node(),
way = iD.Way({nodes: [node1.id, node2.id, node1.id]}),
action = iD.actions.DeleteNode(node2.id),
action = iD.actionDeleteNode(node2.id),
graph = action(iD.Graph([node1, node2, way]));
expect(graph.hasEntity(way.id)).to.be.undefined;
});
@@ -46,7 +46,7 @@ describe('iD.actions.DeleteNode', function () {
it('deletes parent relations that become empty', function () {
var node1 = iD.Node(),
relation = iD.Relation({members: [{ id: node1.id }]}),
action = iD.actions.DeleteNode(node1.id),
action = iD.actionDeleteNode(node1.id),
graph = action(iD.Graph([node1, relation]));
expect(graph.hasEntity(relation.id)).to.be.undefined;
});
+12 -12
View File
@@ -1,7 +1,7 @@
describe('iD.actions.DeleteRelation', function () {
describe('iD.actionDeleteRelation', function () {
it('removes the relation from the graph', function () {
var relation = iD.Relation(),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([relation]));
expect(graph.hasEntity(relation.id)).to.be.undefined;
});
@@ -10,7 +10,7 @@ describe('iD.actions.DeleteRelation', function () {
var a = iD.Relation(),
b = iD.Relation(),
parent = iD.Relation({members: [{ id: a.id }, { id: b.id }]}),
action = iD.actions.DeleteRelation(a.id),
action = iD.actionDeleteRelation(a.id),
graph = action(iD.Graph([a, b, parent]));
expect(graph.entity(parent.id).members).to.eql([{ id: b.id }]);
});
@@ -18,7 +18,7 @@ describe('iD.actions.DeleteRelation', function () {
it('deletes member nodes not referenced by another parent', function() {
var node = iD.Node(),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([node, relation]));
expect(graph.hasEntity(node.id)).to.be.undefined;
});
@@ -27,7 +27,7 @@ describe('iD.actions.DeleteRelation', function () {
var node = iD.Node(),
way = iD.Way({nodes: [node.id]}),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([node, way, relation]));
expect(graph.hasEntity(node.id)).not.to.be.undefined;
});
@@ -35,7 +35,7 @@ describe('iD.actions.DeleteRelation', function () {
it('does not delete member nodes with interesting tags', function() {
var node = iD.Node({tags: {highway: 'traffic_signals'}}),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([node, relation]));
expect(graph.hasEntity(node.id)).not.to.be.undefined;
});
@@ -43,7 +43,7 @@ describe('iD.actions.DeleteRelation', function () {
it('deletes member ways not referenced by another parent', function() {
var way = iD.Way(),
relation = iD.Relation({members: [{id: way.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([way, relation]));
expect(graph.hasEntity(way.id)).to.be.undefined;
});
@@ -52,7 +52,7 @@ describe('iD.actions.DeleteRelation', function () {
var way = iD.Way(),
relation1 = iD.Relation({members: [{id: way.id}]}),
relation2 = iD.Relation({members: [{id: way.id}]}),
action = iD.actions.DeleteRelation(relation1.id),
action = iD.actionDeleteRelation(relation1.id),
graph = action(iD.Graph([way, relation1, relation2]));
expect(graph.hasEntity(way.id)).not.to.be.undefined;
});
@@ -60,7 +60,7 @@ describe('iD.actions.DeleteRelation', function () {
it('does not delete member ways with interesting tags', function() {
var way = iD.Node({tags: {highway: 'residential'}}),
relation = iD.Relation({members: [{id: way.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([way, relation]));
expect(graph.hasEntity(way.id)).not.to.be.undefined;
});
@@ -69,7 +69,7 @@ describe('iD.actions.DeleteRelation', function () {
var node = iD.Node(),
way = iD.Way({nodes: [node.id]}),
relation = iD.Relation({members: [{id: way.id}]}),
action = iD.actions.DeleteRelation(relation.id),
action = iD.actionDeleteRelation(relation.id),
graph = action(iD.Graph([node, way, relation]));
expect(graph.hasEntity(node.id)).to.be.undefined;
});
@@ -77,7 +77,7 @@ describe('iD.actions.DeleteRelation', function () {
it('deletes parent relations that become empty', function () {
var child = iD.Relation(),
parent = iD.Relation({members: [{ id: child.id }]}),
action = iD.actions.DeleteRelation(child.id),
action = iD.actionDeleteRelation(child.id),
graph = action(iD.Graph([child, parent]));
expect(graph.hasEntity(parent.id)).to.be.undefined;
});
@@ -86,7 +86,7 @@ describe('iD.actions.DeleteRelation', function () {
it('returns \'incomplete_relation\' if the relation is incomplete', function() {
var relation = iD.Relation({members: [{id: 'w'}]}),
graph = iD.Graph([relation]),
action = iD.actions.DeleteRelation(relation.id);
action = iD.actionDeleteRelation(relation.id);
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
});
+13 -13
View File
@@ -1,7 +1,7 @@
describe('iD.actions.DeleteWay', function() {
describe('iD.actionDeleteWay', function() {
it('removes the way from the graph', function() {
var way = iD.Way(),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([way]).update(action);
expect(graph.hasEntity(way.id)).to.be.undefined;
});
@@ -9,7 +9,7 @@ describe('iD.actions.DeleteWay', function() {
it('removes a way from parent relations', function() {
var way = iD.Way(),
relation = iD.Relation({members: [{ id: way.id }, { id: 'w-2' }]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([way, relation]).update(action);
expect(_.map(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
});
@@ -17,7 +17,7 @@ describe('iD.actions.DeleteWay', function() {
it('deletes member nodes not referenced by another parent', function() {
var node = iD.Node(),
way = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([node, way]).update(action);
expect(graph.hasEntity(node.id)).to.be.undefined;
});
@@ -26,7 +26,7 @@ describe('iD.actions.DeleteWay', function() {
var node = iD.Node(),
way1 = iD.Way({nodes: [node.id]}),
way2 = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way1.id),
action = iD.actionDeleteWay(way1.id),
graph = iD.Graph([node, way1, way2]).update(action);
expect(graph.hasEntity(node.id)).not.to.be.undefined;
});
@@ -35,7 +35,7 @@ describe('iD.actions.DeleteWay', function() {
var a = iD.Node(),
b = iD.Node(),
way = iD.Way({nodes: [a.id, b.id]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([a, b, way]).update(action);
expect(graph.hasEntity(a.id)).to.be.undefined;
expect(graph.hasEntity(b.id)).to.be.undefined;
@@ -46,7 +46,7 @@ describe('iD.actions.DeleteWay', function() {
b = iD.Node(),
c = iD.Node(),
way = iD.Way({nodes: [a.id, b.id, c.id, a.id]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([a, b, c, way]).update(action);
expect(graph.hasEntity(a.id)).to.be.undefined;
expect(graph.hasEntity(b.id)).to.be.undefined;
@@ -56,7 +56,7 @@ describe('iD.actions.DeleteWay', function() {
it('does not delete member nodes with interesting tags', function() {
var node = iD.Node({tags: {highway: 'traffic_signals'}}),
way = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([node, way]).update(action);
expect(graph.hasEntity(node.id)).not.to.be.undefined;
});
@@ -64,7 +64,7 @@ describe('iD.actions.DeleteWay', function() {
it('deletes parent relations that become empty', function () {
var way = iD.Way(),
relation = iD.Relation({members: [{ id: way.id }]}),
action = iD.actions.DeleteWay(way.id),
action = iD.actionDeleteWay(way.id),
graph = iD.Graph([way, relation]).update(action);
expect(graph.hasEntity(relation.id)).to.be.undefined;
});
@@ -76,15 +76,15 @@ describe('iD.actions.DeleteWay', function() {
route = iD.Relation({members: [{id: 'a'}], tags: {type: 'route'}}),
boundary = iD.Relation({members: [{id: 'b'}], tags: {type: 'boundary'}}),
graph = iD.Graph([a, b, route, boundary]);
expect(iD.actions.DeleteWay('a').disabled(graph)).to.equal('part_of_relation');
expect(iD.actions.DeleteWay('b').disabled(graph)).to.equal('part_of_relation');
expect(iD.actionDeleteWay('a').disabled(graph)).to.equal('part_of_relation');
expect(iD.actionDeleteWay('b').disabled(graph)).to.equal('part_of_relation');
});
it('returns \'part_of_relation\' for outer members of multipolygons', function () {
var way = iD.Way({id: 'w'}),
relation = iD.Relation({members: [{id: 'w', role: 'outer'}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([way, relation]),
action = iD.actions.DeleteWay(way.id);
action = iD.actionDeleteWay(way.id);
expect(action.disabled(graph)).to.equal('part_of_relation');
});
@@ -92,7 +92,7 @@ describe('iD.actions.DeleteWay', function() {
var way = iD.Way({id: 'w'}),
relation = iD.Relation({members: [{id: 'w', role: 'inner'}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([way, relation]),
action = iD.actions.DeleteWay(way.id);
action = iD.actionDeleteWay(way.id);
expect(action.disabled(graph)).not.ok;
});
});
+5 -5
View File
@@ -1,9 +1,9 @@
describe('iD.actions.DiscardTags', function() {
describe('iD.actionDiscardTags', function() {
it('discards obsolete tags from modified entities', function() {
var way = iD.Way({id: 'w1', tags: {created_by: 'Potlatch'}}),
base = iD.Graph([way]),
head = base.replace(way.update({tags: {created_by: 'Potlatch', foo: 'bar'}})),
action = iD.actions.DiscardTags(iD.Difference(base, head));
action = iD.actionDiscardTags(iD.Difference(base, head));
expect(action(head).entity(way.id).tags).to.eql({foo: 'bar'});
});
@@ -11,7 +11,7 @@ describe('iD.actions.DiscardTags', function() {
var way = iD.Way({tags: {created_by: 'Potlatch'}}),
base = iD.Graph(),
head = base.replace(way),
action = iD.actions.DiscardTags(iD.Difference(base, head));
action = iD.actionDiscardTags(iD.Difference(base, head));
expect(action(head).entity(way.id).tags).to.eql({});
});
@@ -19,7 +19,7 @@ describe('iD.actions.DiscardTags', function() {
var way = iD.Way(),
base = iD.Graph(),
head = base.replace(way),
action = iD.actions.DiscardTags(iD.Difference(base, head));
action = iD.actionDiscardTags(iD.Difference(base, head));
expect(action(head).entity(way.id)).to.equal(way);
});
@@ -27,7 +27,7 @@ describe('iD.actions.DiscardTags', function() {
var way = iD.Way({tags: {lmnop: ''}}),
base = iD.Graph(),
head = base.replace(way),
action = iD.actions.DiscardTags(iD.Difference(base, head));
action = iD.actionDiscardTags(iD.Difference(base, head));
expect(action(head).entity(way.id).tags).to.eql({});
});
});
+17 -17
View File
@@ -1,8 +1,8 @@
describe('iD.actions.Disconnect', function () {
describe('iD.actionDisconnect', function () {
describe('#disabled', function () {
it('returns \'not_connected\' for a node shared by less than two ways', function () {
var graph = iD.Graph([iD.Node({id: 'a'})]);
expect(iD.actions.Disconnect('a').disabled(graph)).to.equal('not_connected');
expect(iD.actionDisconnect('a').disabled(graph)).to.equal('not_connected');
});
it('returns falsy for the closing node in a closed line', function () {
@@ -16,7 +16,7 @@ describe('iD.actions.Disconnect', function () {
iD.Node({id: 'd'}),
iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'a']})
]);
expect(iD.actions.Disconnect('a').disabled(graph)).not.to.be.ok;
expect(iD.actionDisconnect('a').disabled(graph)).not.to.be.ok;
});
it('returns not_connected for the closing node in a closed area', function () {
@@ -30,7 +30,7 @@ describe('iD.actions.Disconnect', function () {
iD.Node({id: 'd'}),
iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'a'], tags: {area: 'yes'}})
]);
expect(iD.actions.Disconnect('a').disabled(graph)).to.equal('not_connected');
expect(iD.actionDisconnect('a').disabled(graph)).to.equal('not_connected');
});
it('returns falsy for a shared non-closing node in an area', function () {
@@ -46,7 +46,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'e', 'b', 'a'], tags: {area: 'yes'}})
]);
expect(iD.actions.Disconnect('b').disabled(graph)).not.to.be.ok;
expect(iD.actionDisconnect('b').disabled(graph)).not.to.be.ok;
});
it('returns falsy for a node shared by two or more ways', function () {
@@ -62,7 +62,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
expect(iD.actions.Disconnect('b').disabled(graph)).not.to.be.ok;
expect(iD.actionDisconnect('b').disabled(graph)).not.to.be.ok;
});
it('returns falsy for an intersection of two ways with parent way specified', function () {
@@ -78,7 +78,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
expect(iD.actions.Disconnect('b', ['|']).disabled(graph)).not.to.be.ok;
expect(iD.actionDisconnect('b', ['|']).disabled(graph)).not.to.be.ok;
});
it('returns \'relation\' for a node connecting any two members of the same relation', function () {
@@ -96,7 +96,7 @@ describe('iD.actions.Disconnect', function () {
]})
]);
expect(iD.actions.Disconnect('b').disabled(graph)).to.eql('relation');
expect(iD.actionDisconnect('b').disabled(graph)).to.eql('relation');
});
it('returns falsy for a node connecting two members of an unaffected relation', function () {
@@ -118,7 +118,7 @@ describe('iD.actions.Disconnect', function () {
]})
]);
expect(iD.actions.Disconnect('b').limitWays(['|']).disabled(graph)).not.to.be.ok;
expect(iD.actionDisconnect('b').limitWays(['|']).disabled(graph)).not.to.be.ok;
});
});
@@ -145,7 +145,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
graph = iD.actions.Disconnect('b', 'e')(graph);
graph = iD.actionDisconnect('b', 'e')(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
expect(graph.entity('|').nodes).to.eql(['d', 'e']);
@@ -173,7 +173,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
graph = iD.actions.Disconnect('b', 'e').limitWays(['-'])(graph);
graph = iD.actionDisconnect('b', 'e').limitWays(['-'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'e']);
expect(graph.entity('=').nodes).to.eql(['b', 'c']);
@@ -199,7 +199,7 @@ describe('iD.actions.Disconnect', function () {
iD.Node({id: 'c'}),
iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'a']})
]);
graph = iD.actions.Disconnect('a', 'd')(graph);
graph = iD.actionDisconnect('a', 'd')(graph);
expect(graph.entity('w').nodes).to.eql(['a', 'b', 'c', 'd']);
});
@@ -228,7 +228,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: 'w2', nodes: ['b', 'c', 'd', 'e', 'b']})
]);
graph = iD.actions.Disconnect('b', '*')(graph);
graph = iD.actionDisconnect('b', '*')(graph);
expect(graph.entity('w1').nodes).to.eql(['a', 'b']);
expect(graph.entity('w2').nodes).to.eql(['*', 'c', 'd', 'e', '*']);
@@ -256,7 +256,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'e', 'b', 'a'], tags: {area: 'yes'}})
]);
graph = iD.actions.Disconnect('b', '*')(graph);
graph = iD.actionDisconnect('b', '*')(graph);
expect(graph.entity('w').nodes).to.eql(['a', 'b', 'c', 'd', 'e', '*', 'a']);
});
@@ -288,7 +288,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: 'w2', nodes: ['b', 'd', 'e', 'b'], tags: {area: 'yes'}})
]);
graph = iD.actions.Disconnect('b', '*')(graph);
graph = iD.actionDisconnect('b', '*')(graph);
expect(graph.entity('w1').nodes).to.eql(['a', 'b', 'c', 'a']);
expect(graph.entity('w2').nodes).to.eql(['*', 'd', 'e', '*']);
@@ -321,7 +321,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: 'w2', nodes: ['b', 'd', 'e', 'b'], tags: {area: 'yes'}})
]);
graph = iD.actions.Disconnect('b', '*')(graph);
graph = iD.actionDisconnect('b', '*')(graph);
expect(graph.entity('w1').nodes).to.eql(['b', 'c', 'a', 'b']);
expect(graph.entity('w2').nodes).to.eql(['*', 'd', 'e', '*']);
@@ -339,7 +339,7 @@ describe('iD.actions.Disconnect', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
graph = iD.actions.Disconnect('b', 'e')(graph);
graph = iD.actionDisconnect('b', 'e')(graph);
// Immutable loc => should be shared by identity.
expect(graph.entity('b').loc).to.equal(loc);
+29 -29
View File
@@ -1,4 +1,4 @@
describe('iD.actions.Join', function () {
describe('iD.actionJoin', function () {
describe('#disabled', function () {
it('returns falsy for ways that share an end/start node', function () {
// a --> b ==> c
@@ -10,7 +10,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c']})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for ways that share a start/end node', function () {
@@ -23,7 +23,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['c', 'b']})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for ways that share a start/start node', function () {
@@ -36,7 +36,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c']})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for ways that share an end/end node', function () {
@@ -49,7 +49,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['c', 'b']})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for more than two ways when connected, regardless of order', function () {
@@ -64,12 +64,12 @@ describe('iD.actions.Join', function () {
iD.Way({id: '~', nodes: ['c', 'd']})
]);
expect(iD.actions.Join(['-', '=', '~']).disabled(graph)).not.to.be.ok;
expect(iD.actions.Join(['-', '~', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actions.Join(['=', '-', '~']).disabled(graph)).not.to.be.ok;
expect(iD.actions.Join(['=', '~', '-']).disabled(graph)).not.to.be.ok;
expect(iD.actions.Join(['~', '=', '-']).disabled(graph)).not.to.be.ok;
expect(iD.actions.Join(['~', '-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=', '~']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '~', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['=', '-', '~']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['=', '~', '-']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['~', '=', '-']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['~', '-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns \'not_eligible\' for non-line geometries', function () {
@@ -77,7 +77,7 @@ describe('iD.actions.Join', function () {
iD.Node({id: 'a'})
]);
expect(iD.actions.Join(['a']).disabled(graph)).to.equal('not_eligible');
expect(iD.actionJoin(['a']).disabled(graph)).to.equal('not_eligible');
});
it('returns \'not_adjacent\' for ways that don\'t share the necessary nodes', function () {
@@ -93,7 +93,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'd']})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('not_adjacent');
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal('not_adjacent');
});
it('returns \'restriction\' in situations where a turn restriction would be damaged (a)', function () {
@@ -114,7 +114,7 @@ describe('iD.actions.Join', function () {
]})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('restriction');
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal('restriction');
});
it('returns \'restriction\' in situations where a turn restriction would be damaged (b)', function () {
@@ -139,7 +139,7 @@ describe('iD.actions.Join', function () {
]})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('restriction');
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal('restriction');
});
it('returns falsy in situations where a turn restriction wouldn\'t be damaged (a)', function () {
@@ -164,7 +164,7 @@ describe('iD.actions.Join', function () {
]})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy in situations where a turn restriction wouldn\'t be damaged (b)', function () {
@@ -192,7 +192,7 @@ describe('iD.actions.Join', function () {
]})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns \'conflicting_tags\' for two entities that have conflicting tags', function () {
@@ -204,7 +204,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c'], tags: {highway: 'secondary'}})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('conflicting_tags');
expect(iD.actionJoin(['-', '=']).disabled(graph)).to.equal('conflicting_tags');
});
it('takes tag reversals into account when calculating conflicts', function () {
@@ -216,7 +216,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['c', 'b'], tags: {'oneway': '-1'}})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for exceptions to tag conflicts: missing tag', function () {
@@ -228,7 +228,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c'], tags: {}})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for exceptions to tag conflicts: uninteresting tag', function () {
@@ -240,7 +240,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c'], tags: {'tiger:cfcc': 'A42'}})
]);
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
expect(iD.actionJoin(['-', '=']).disabled(graph)).not.to.be.ok;
});
});
@@ -255,7 +255,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c']})
]);
graph = iD.actions.Join(['-', '='])(graph);
graph = iD.actionJoin(['-', '='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
expect(graph.hasEntity('=')).to.be.undefined;
@@ -272,7 +272,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['c', 'b']})
]);
graph = iD.actions.Join(['-', '='])(graph);
graph = iD.actionJoin(['-', '='])(graph);
expect(graph.entity('-').nodes).to.eql(['c', 'b', 'a']);
expect(graph.hasEntity('=')).to.be.undefined;
@@ -290,7 +290,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['b', 'c'], tags: {'lanes:forward': 2}})
]);
graph = iD.actions.Join(['-', '='])(graph);
graph = iD.actionJoin(['-', '='])(graph);
expect(graph.entity('-').nodes).to.eql(['c', 'b', 'a']);
expect(graph.hasEntity('=')).to.be.undefined;
@@ -309,7 +309,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '=', nodes: ['c', 'b'], tags: {'lanes:forward': 2}})
]);
graph = iD.actions.Join(['-', '='])(graph);
graph = iD.actionJoin(['-', '='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
expect(graph.hasEntity('=')).to.be.undefined;
@@ -332,7 +332,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '*', nodes: ['d', 'e'], tags: {'lanes:backward': 2}})
]);
graph = iD.actions.Join(['-', '=', '+', '*'])(graph);
graph = iD.actionJoin(['-', '=', '+', '*'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c', 'd', 'e']);
expect(graph.hasEntity('=')).to.be.undefined;
@@ -356,7 +356,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: 'w-2', nodes: ['c', 'd']})
]);
graph = iD.actions.Join(['w-1', 'w1', 'w-2'])(graph);
graph = iD.actionJoin(['w-1', 'w1', 'w-2'])(graph);
expect(graph.entity('w1').nodes).to.eql(['a', 'b', 'c', 'd']);
expect(graph.hasEntity('w-1')).to.be.undefined;
@@ -374,7 +374,7 @@ describe('iD.actions.Join', function () {
iD.Way({id: '+', nodes: ['c', 'd'], tags: {a: 'a', b: '=', e: 'e'}})
]);
graph = iD.actions.Join(['-', '=', '+'])(graph);
graph = iD.actionJoin(['-', '=', '+'])(graph);
expect(graph.entity('-').tags).to.eql({a: 'a', b: '-;=', c: 'c', d: 'd', e: 'e'});
});
@@ -390,7 +390,7 @@ describe('iD.actions.Join', function () {
iD.Relation({id: 'r2', members: [{id: '=', role: 'r2', type: 'way'}, {id: '-', role: 'r2', type: 'way'}]})
]);
graph = iD.actions.Join(['-', '='])(graph);
graph = iD.actionJoin(['-', '='])(graph);
expect(graph.entity('r1').members).to.eql([{id: '-', role: 'r1', type: 'way'}]);
expect(graph.entity('r2').members).to.eql([{id: '-', role: 'r2', type: 'way'}]);
+3 -3
View File
@@ -1,4 +1,4 @@
describe('iD.actions.Merge', function () {
describe('iD.actionMerge', function () {
it('merges multiple points to a line', function () {
var graph = iD.Graph([
iD.Node({id: 'a', tags: {a: 'a'}}),
@@ -6,7 +6,7 @@ describe('iD.actions.Merge', function () {
iD.Way({id: 'w'}),
iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]})
]),
action = iD.actions.Merge(['a', 'b', 'w']);
action = iD.actionMerge(['a', 'b', 'w']);
expect(action.disabled(graph)).not.to.be.ok;
@@ -25,7 +25,7 @@ describe('iD.actions.Merge', function () {
iD.Way({id: 'w', tags: {area: 'yes'}}),
iD.Relation({id: 'r', members: [{id: 'a', role: 'r', type: 'node'}]})
]),
action = iD.actions.Merge(['a', 'b', 'w']);
action = iD.actionMerge(['a', 'b', 'w']);
expect(action.disabled(graph)).not.to.be.ok;
+16 -16
View File
@@ -1,4 +1,4 @@
describe('iD.actions.MergePolygon', function () {
describe('iD.actionMergePolygon', function () {
function node(id, x, y) {
e.push(iD.Node({ id: id, loc: [x, y] }));
@@ -51,7 +51,7 @@ describe('iD.actions.MergePolygon', function () {
}
it('creates a multipolygon from two closed ways', function() {
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
var r = graph.entity('r');
expect(!!r).to.equal(true);
expect(r.geometry(graph)).to.equal('area');
@@ -64,16 +64,16 @@ describe('iD.actions.MergePolygon', function () {
});
it('creates a multipolygon from a closed way and a multipolygon relation', function() {
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actions.MergePolygon(['r', 'w2'])(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['r', 'w2'])(graph);
var r = graph.entity('r');
expect(r.members.length).to.equal(3);
});
it('creates a multipolygon from two multipolygon relations', function() {
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actions.MergePolygon(['w2', 'w5'], 'r2')(graph);
graph = iD.actions.MergePolygon(['r', 'r2'])(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['w2', 'w5'], 'r2')(graph);
graph = iD.actionMergePolygon(['r', 'r2'])(graph);
// Delete other relation
expect(graph.hasEntity('r2')).to.equal(undefined);
@@ -91,7 +91,7 @@ describe('iD.actions.MergePolygon', function () {
iD.Relation({id: 'r2', tags: {type: 'multipolygon', b: 'b'}})
]);
graph = iD.actions.MergePolygon(['r1', 'r2'])(graph);
graph = iD.actionMergePolygon(['r1', 'r2'])(graph);
expect(graph.entity('r1').tags.a).to.equal('a');
expect(graph.entity('r1').tags.b).to.equal('b');
@@ -99,7 +99,7 @@ describe('iD.actions.MergePolygon', function () {
it('merges tags from closed outer ways', function() {
graph = graph.replace(graph.entity('w0').update({ tags: { 'building': 'yes' }}));
graph = iD.actions.MergePolygon(['w0', 'w5'], 'r')(graph);
graph = iD.actionMergePolygon(['w0', 'w5'], 'r')(graph);
expect(graph.entity('w0').tags.building).to.equal(undefined);
expect(graph.entity('r').tags.building).to.equal('yes');
});
@@ -115,35 +115,35 @@ describe('iD.actions.MergePolygon', function () {
]});
graph = graph.replace(r1).replace(r2);
graph = iD.actions.MergePolygon(['r1', 'r2'])(graph);
graph = iD.actionMergePolygon(['r1', 'r2'])(graph);
expect(graph.entity('w3').tags.natural).to.equal('water');
expect(graph.entity('r1').tags.natural).to.equal(undefined);
});
it('merges no tags from inner ways', function() {
graph = graph.replace(graph.entity('w1').update({ tags: { 'natural': 'water' }}));
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
expect(graph.entity('w1').tags.natural).to.equal('water');
expect(graph.entity('r').tags.natural).to.equal(undefined);
});
it('doesn\'t copy area tags from ways', function() {
graph = graph.replace(graph.entity('w0').update({ tags: { 'area': 'yes' }}));
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
var r = graph.entity('r');
expect(r.tags.area).to.equal(undefined);
});
it('creates a multipolygon with two disjunct outer rings', function() {
graph = iD.actions.MergePolygon(['w0', 'w5'], 'r')(graph);
graph = iD.actionMergePolygon(['w0', 'w5'], 'r')(graph);
var r = graph.entity('r');
expect(find(r, 'w0').role).to.equal('outer');
expect(find(r, 'w5').role).to.equal('outer');
});
it('creates a multipolygon with an island in a hole', function() {
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actions.MergePolygon(['r', 'w2'])(graph);
graph = iD.actionMergePolygon(['w0', 'w1'], 'r')(graph);
graph = iD.actionMergePolygon(['r', 'w2'])(graph);
var r = graph.entity('r');
expect(find(r, 'w0').role).to.equal('outer');
expect(find(r, 'w1').role).to.equal('inner');
@@ -157,7 +157,7 @@ describe('iD.actions.MergePolygon', function () {
{ type: 'way', role: 'inner', id: 'w4' }
]});
graph = graph.replace(r);
graph = iD.actions.MergePolygon(['r', 'w2'])(graph);
graph = iD.actionMergePolygon(['r', 'w2'])(graph);
r = graph.entity('r');
expect(find(r, 'w0').role).to.equal('outer');
expect(find(r, 'w2').role).to.equal('outer');
+28 -28
View File
@@ -1,6 +1,6 @@
/* global locale: true */
/* eslint no-console: 0 */
describe('iD.actions.MergeRemoteChanges', function () {
describe('iD.actionMergeRemoteChanges', function () {
var base = iD.Graph([
iD.Node({id: 'a', loc: [1, 1], version: '1', tags: {foo: 'foo'}}),
@@ -102,7 +102,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph);
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph);
var result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -115,7 +115,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -128,7 +128,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -141,7 +141,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -155,7 +155,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('a').version).to.eql('2');
@@ -170,7 +170,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('a').version).to.eql('2');
@@ -189,7 +189,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -205,7 +205,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('a').version).to.eql('2');
@@ -224,7 +224,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -241,7 +241,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote, r2, r3]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -261,7 +261,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, r2, r3]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -280,7 +280,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, r1, r2]),
remoteGraph = makeGraph([remote, r3, r4]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -299,7 +299,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, r1, r2]),
remoteGraph = makeGraph([remote, r3, r4]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -312,7 +312,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('p1').update({loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('p1').version).to.eql('2');
@@ -326,7 +326,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('p1').update({loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -344,7 +344,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('r').update({tags: remoteTags, members: remoteMembers, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote, s1, s2, s3, s4, w4]),
action = iD.actions.MergeRemoteChanges('r', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('r', localGraph, remoteGraph),
result = action(localGraph);
expect(result).to.eql(localGraph);
@@ -360,7 +360,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('r').update({tags: remoteTags, members: remoteMembers, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('r', localGraph, remoteGraph),
action = iD.actionMergeRemoteChanges('r', localGraph, remoteGraph),
result = action(localGraph);
expect(result.entity('r').version).to.eql('2');
@@ -378,7 +378,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph);
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph);
action(localGraph);
expect(action.conflicts()).not.to.be.empty;
@@ -398,7 +398,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph).withOption('force_local'),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph).withOption('force_local'),
result = action(localGraph);
expect(result.entity('a').version).to.eql('2');
@@ -415,7 +415,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('a').update({tags: remoteTags, loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph).withOption('force_remote'),
action = iD.actionMergeRemoteChanges('a', localGraph, remoteGraph).withOption('force_remote'),
result = action(localGraph);
expect(result.entity('a').version).to.eql('2');
@@ -435,7 +435,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, r1, r2]),
remoteGraph = makeGraph([remote, r3, r4]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_local'),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_local'),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -452,7 +452,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({tags: remoteTags, nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, r1, r2]),
remoteGraph = makeGraph([remote, r3, r4]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
result = action(localGraph);
expect(result.entity('w1').version).to.eql('2');
@@ -469,7 +469,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('p1').update({loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_local'),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_local'),
result = action(localGraph);
expect(result.entity('p1').version).to.eql('2');
@@ -483,7 +483,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('p1').update({loc: remoteLoc, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
result = action(localGraph);
expect(result.entity('p1').version).to.eql('2');
@@ -498,7 +498,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('w1').update({nodes: remoteNodes, version: '2'}),
localGraph = makeGraph([local, localr1, r2]),
remoteGraph = makeGraph([remote, r3, r4]),
action = iD.actions.MergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
action = iD.actionMergeRemoteChanges('w1', localGraph, remoteGraph).withOption('force_remote'),
result = action(localGraph);
expect(result.entity('w1').nodes).to.eql(remoteNodes);
@@ -518,7 +518,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('r').update({tags: remoteTags, members: remoteMembers, version: '2'}),
localGraph = makeGraph([local, r1, r2, r3, r4, w3]),
remoteGraph = makeGraph([remote, s1, s2, s3, s4, w4]),
action = iD.actions.MergeRemoteChanges('r', localGraph, remoteGraph).withOption('force_local'),
action = iD.actionMergeRemoteChanges('r', localGraph, remoteGraph).withOption('force_local'),
result = action(localGraph);
expect(result.entity('r').version).to.eql('2');
@@ -535,7 +535,7 @@ describe('iD.actions.MergeRemoteChanges', function () {
remote = base.entity('r').update({tags: remoteTags, members: remoteMembers, version: '2'}),
localGraph = makeGraph([local, r1, r2, r3, r4, w3]),
remoteGraph = makeGraph([remote, s1, s2, s3, s4, w4]),
action = iD.actions.MergeRemoteChanges('r', localGraph, remoteGraph).withOption('force_remote'),
action = iD.actionMergeRemoteChanges('r', localGraph, remoteGraph).withOption('force_remote'),
result = action(localGraph);
expect(result.entity('r').version).to.eql('2');
+8 -8
View File
@@ -1,17 +1,17 @@
describe('iD.actions.Move', function() {
describe('iD.actionMove', function() {
var projection = d3.geoMercator().scale(250 / Math.PI);
describe('#disabled', function() {
it('returns falsy by default', function() {
var node = iD.Node({loc: [0, 0]}),
action = iD.actions.Move([node.id], [0, 0], projection),
action = iD.actionMove([node.id], [0, 0], projection),
graph = iD.Graph([node]);
expect(action.disabled(graph)).not.to.be.ok;
});
it('returns \'incomplete_relation\' for an incomplete relation', function() {
var relation = iD.Relation({members: [{id: 1}]}),
action = iD.actions.Move([relation.id], [0, 0], projection),
action = iD.actionMove([relation.id], [0, 0], projection),
graph = iD.Graph([relation]);
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
@@ -19,7 +19,7 @@ describe('iD.actions.Move', function() {
it('returns falsy for a complete relation', function() {
var node = iD.Node({loc: [0, 0]}),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.Move([relation.id], [0, 0], projection),
action = iD.actionMove([relation.id], [0, 0], projection),
graph = iD.Graph([node, relation]);
expect(action.disabled(graph)).not.to.be.ok;
});
@@ -30,7 +30,7 @@ describe('iD.actions.Move', function() {
node2 = iD.Node({loc: [5, 10]}),
way = iD.Way({nodes: [node1.id, node2.id]}),
delta = [2, 3],
graph = iD.actions.Move([way.id], delta, projection)(iD.Graph([node1, node2, way])),
graph = iD.actionMove([way.id], delta, projection)(iD.Graph([node1, node2, way])),
loc1 = graph.entity(node1.id).loc,
loc2 = graph.entity(node2.id).loc;
expect(loc1[0]).to.be.closeTo( 1.440, 0.001);
@@ -43,7 +43,7 @@ describe('iD.actions.Move', function() {
var node = iD.Node({loc: [0, 0]}),
way = iD.Way({nodes: [node.id, node.id]}),
delta = [2, 3],
graph = iD.actions.Move([way.id], delta, projection)(iD.Graph([node, way])),
graph = iD.actionMove([way.id], delta, projection)(iD.Graph([node, way])),
loc = graph.entity(node.id).loc;
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
expect(loc[1]).to.be.closeTo(-2.159, 0.001);
@@ -54,7 +54,7 @@ describe('iD.actions.Move', function() {
way1 = iD.Way({nodes: [node.id]}),
way2 = iD.Way({nodes: [node.id]}),
delta = [2, 3],
graph = iD.actions.Move([way1.id, way2.id], delta, projection)(iD.Graph([node, way1, way2])),
graph = iD.actionMove([way1.id, way2.id], delta, projection)(iD.Graph([node, way1, way2])),
loc = graph.entity(node.id).loc;
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
expect(loc[1]).to.be.closeTo(-2.159, 0.001);
@@ -65,7 +65,7 @@ describe('iD.actions.Move', function() {
way = iD.Way({nodes: [node.id]}),
relation = iD.Relation({members: [{id: way.id}]}),
delta = [2, 3],
graph = iD.actions.Move([relation.id], delta, projection)(iD.Graph([node, way, relation])),
graph = iD.actionMove([relation.id], delta, projection)(iD.Graph([node, way, relation])),
loc = graph.entity(node.id).loc;
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
expect(loc[1]).to.be.closeTo(-2.159, 0.001);
+2 -2
View File
@@ -1,8 +1,8 @@
describe('iD.actions.MoveNode', function () {
describe('iD.actionMoveNode', function () {
it('changes a node\'s location', function () {
var node = iD.Node(),
loc = [2, 3],
graph = iD.actions.MoveNode(node.id, loc)(iD.Graph([node]));
graph = iD.actionMoveNode(node.id, loc)(iD.Graph([node]));
expect(graph.entity(node.id).loc).to.eql(loc);
});
});
+2 -2
View File
@@ -1,7 +1,7 @@
describe('iD.actions.Noop', function () {
describe('iD.actionNoop', function () {
it('does nothing', function () {
var graph = iD.Graph(),
action = iD.actions.Noop(graph);
action = iD.actionNoop(graph);
expect(action(graph)).to.equal(graph);
});
});
+10 -10
View File
@@ -1,4 +1,4 @@
describe('iD.actions.Orthogonalize', function () {
describe('iD.actionOrthogonalize', function () {
var projection = d3.geoMercator();
it('orthogonalizes a perfect quad', function () {
@@ -10,7 +10,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
]);
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
expect(graph.entity('-').nodes).to.have.length(5);
});
@@ -24,7 +24,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
]);
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
expect(graph.entity('-').nodes).to.have.length(5);
});
@@ -37,7 +37,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a']})
]);
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
expect(graph.entity('-').nodes).to.have.length(4);
});
@@ -52,7 +52,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']})
]);
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
expect(graph.hasEntity('d')).to.eq(undefined);
});
@@ -67,7 +67,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'a']})
]);
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
expect(graph.entity('-').nodes).to.have.length(6);
expect(graph.hasEntity('d')).to.not.eq(undefined);
@@ -97,12 +97,12 @@ describe('iD.actions.Orthogonalize', function () {
iD.Node({id: 'd', loc: tests[i][3]}),
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
]),
initialWidth = iD.geo.sphericalDistance(graph.entity('a').loc, graph.entity('b').loc),
initialWidth = iD.geoSphericalDistance(graph.entity('a').loc, graph.entity('b').loc),
finalWidth;
graph = iD.actions.Orthogonalize('-', projection)(graph);
graph = iD.actionOrthogonalize('-', projection)(graph);
finalWidth = iD.geo.sphericalDistance(graph.entity('a').loc, graph.entity('b').loc);
finalWidth = iD.geoSphericalDistance(graph.entity('a').loc, graph.entity('b').loc);
expect(finalWidth / initialWidth).within(0.90, 1.10);
}
});
@@ -117,7 +117,7 @@ describe('iD.actions.Orthogonalize', function () {
iD.Node({id: 'f', loc: [0, 2]}),
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'e', 'f', 'a']})
]),
diff = iD.Difference(graph, iD.actions.Orthogonalize('-', projection)(graph));
diff = iD.Difference(graph, iD.actionOrthogonalize('-', projection)(graph));
expect(Object.keys(diff.changes()).sort()).to.eql(['a', 'b', 'c', 'f']);
});
+21 -21
View File
@@ -1,4 +1,4 @@
describe('iD.actions.RestrictTurn', function() {
describe('iD.actionRestrictTurn', function() {
var projection = d3.geoMercator().scale(250 / Math.PI);
it('adds a restriction to an unrestricted turn', function() {
@@ -10,7 +10,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*']}),
iD.Way({id: '-', nodes: ['*', 'w']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'w', way: '-'},
@@ -38,7 +38,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'x', way: '-'},
@@ -66,7 +66,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'w', way: '=', newID: '=='},
via: {node: '*'},
to: {node: 'x', way: '-'},
@@ -94,7 +94,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'u', way: '=', newID: '=='},
via: {node: '*'},
to: {node: 'w', way: '='},
@@ -122,7 +122,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['w', '*', 'u']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'u', way: '=', newID: '=='},
via: {node: '*'},
to: {node: 'w', way: '='},
@@ -153,7 +153,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*']}),
iD.Way({id: '=', nodes: ['*', 'w']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'c', way: '-', newID: '--'},
via: {node: '*'},
to: {node: 'w', way: '='},
@@ -184,7 +184,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*']}),
iD.Way({id: '=', nodes: ['*', 'w']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'a', way: '-', newID: '--'},
via: {node: '*'},
to: {node: 'c', way: '-'},
@@ -212,7 +212,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'x', way: '-'},
via: {node: '*'},
to: {node: 'w', way: '=', newID: '=='},
@@ -240,7 +240,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'x', way: '-'},
via: {node: '*'},
to: {node: 'u', way: '='},
@@ -271,7 +271,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*']}),
iD.Way({id: '=', nodes: ['*', 'w']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'w', way: '='},
via: {node: '*'},
to: {node: 'c', way: '-', newID: '--'},
@@ -299,7 +299,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'u', way: '='},
@@ -327,7 +327,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '=', nodes: ['u', '*', 'w']}),
iD.Way({id: '-', nodes: ['*', 'x']})
]),
action = iD.actions.RestrictTurn({
action = iD.actionRestrictTurn({
from: {node: 'w', way: '=', newID: '=='},
via: {node: '*'},
to: {node: 'w', way: '=', newID: '~~'},
@@ -357,42 +357,42 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: '~', nodes: ['*', 'w']})
]);
var r1 = iD.actions.RestrictTurn({
var r1 = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'x', way: '-'}
}, projection, 'r')(graph);
expect(r1.entity('r').tags.restriction).to.equal('no_right_turn');
var r2 = iD.actions.RestrictTurn({
var r2 = iD.actionRestrictTurn({
from: {node: 'x', way: '-'},
via: {node: '*'},
to: {node: 'w', way: '~'}
}, projection, 'r')(graph);
expect(r2.entity('r').tags.restriction).to.equal('no_right_turn');
var l1 = iD.actions.RestrictTurn({
var l1 = iD.actionRestrictTurn({
from: {node: 'x', way: '-'},
via: {node: '*'},
to: {node: 'u', way: '='}
}, projection, 'r')(graph);
expect(l1.entity('r').tags.restriction).to.equal('no_left_turn');
var l2 = iD.actions.RestrictTurn({
var l2 = iD.actionRestrictTurn({
from: {node: 'w', way: '~'},
via: {node: '*'},
to: {node: 'x', way: '-'}
}, projection, 'r')(graph);
expect(l2.entity('r').tags.restriction).to.equal('no_left_turn');
var s = iD.actions.RestrictTurn({
var s = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'w', way: '~'}
}, projection, 'r')(graph);
expect(s.entity('r').tags.restriction).to.equal('no_straight_on');
var u = iD.actions.RestrictTurn({
var u = iD.actionRestrictTurn({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'u', way: '='}
@@ -414,7 +414,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: 'w2', nodes: ['*', 'u'], tags: {oneway: 'yes'}})
]);
var r = iD.actions.RestrictTurn({
var r = iD.actionRestrictTurn({
from: {node: 'x', way: 'w1'},
via: {node: '*'},
to: {node: 'u', way: 'w2'}
@@ -436,7 +436,7 @@ describe('iD.actions.RestrictTurn', function() {
iD.Way({id: 'w2', nodes: ['u', '*'], tags: {oneway: '-1'}})
]);
var r = iD.actions.RestrictTurn({
var r = iD.actionRestrictTurn({
from: {node: 'x', way: 'w1'},
via: {node: '*'},
to: {node: 'u', way: 'w2'}
+28 -28
View File
@@ -1,9 +1,9 @@
describe('iD.actions.Reverse', function () {
describe('iD.actionReverse', function () {
it('reverses the order of nodes in the way', function () {
var node1 = iD.Node(),
node2 = iD.Node(),
way = iD.Way({nodes: [node1.id, node2.id]}),
graph = iD.actions.Reverse(way.id)(iD.Graph([node1, node2, way]));
graph = iD.actionReverse(way.id)(iD.Graph([node1, node2, way]));
expect(graph.entity(way.id).nodes).to.eql([node2.id, node1.id]);
});
@@ -11,7 +11,7 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'highway': 'residential'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'highway': 'residential'});
});
@@ -19,7 +19,7 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'oneway': 'yes'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'oneway': 'yes'});
});
@@ -31,13 +31,13 @@ describe('iD.actions.Reverse', function () {
iD.Way({id: '-1', tags: {oneway: '-1'}})
]);
expect(iD.actions.Reverse('yes', {reverseOneway: true})(graph)
expect(iD.actionReverse('yes', {reverseOneway: true})(graph)
.entity('yes').tags).to.eql({oneway: '-1'});
expect(iD.actions.Reverse('no', {reverseOneway: true})(graph)
expect(iD.actionReverse('no', {reverseOneway: true})(graph)
.entity('no').tags).to.eql({oneway: 'no'});
expect(iD.actions.Reverse('1', {reverseOneway: true})(graph)
expect(iD.actionReverse('1', {reverseOneway: true})(graph)
.entity('1').tags).to.eql({oneway: '-1'});
expect(iD.actions.Reverse('-1', {reverseOneway: true})(graph)
expect(iD.actionReverse('-1', {reverseOneway: true})(graph)
.entity('-1').tags).to.eql({oneway: 'yes'});
});
@@ -45,10 +45,10 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'cycleway:right': 'lane'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'cycleway:left': 'lane'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'cycleway:right': 'lane'});
});
@@ -56,10 +56,10 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'maxspeed:forward': '25'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'maxspeed:backward': '25'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'maxspeed:forward': '25'});
});
@@ -67,10 +67,10 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'incline': 'up'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': 'down'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': 'up'});
});
@@ -78,10 +78,10 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'incline': 'up'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': 'down'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': 'up'});
});
@@ -89,16 +89,16 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'incline': '5%'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': '-5%'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': '5%'});
way = iD.Way({tags: {'incline': '.8°'}});
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'incline': '-.8°'});
});
@@ -106,10 +106,10 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'sidewalk': 'right'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'sidewalk': 'left'});
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'sidewalk': 'right'});
});
@@ -117,7 +117,7 @@ describe('iD.actions.Reverse', function () {
var way = iD.Way({tags: {'maxspeed:forward': '25', 'maxspeed:backward': '30'}}),
graph = iD.Graph([way]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(way.id).tags).to.eql({'maxspeed:backward': '25', 'maxspeed:forward': '30'});
});
@@ -126,10 +126,10 @@ describe('iD.actions.Reverse', function () {
relation = iD.Relation({members: [{type: 'way', id: way.id, role: 'forward'}]}),
graph = iD.Graph([way, relation]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('backward');
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('forward');
});
@@ -138,10 +138,10 @@ describe('iD.actions.Reverse', function () {
relation = iD.Relation({members: [{type: 'way', id: way.id, role: 'north'}]}),
graph = iD.Graph([way, relation]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('south');
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('north');
});
@@ -150,10 +150,10 @@ describe('iD.actions.Reverse', function () {
relation = iD.Relation({members: [{type: 'way', id: way.id, role: 'east'}]}),
graph = iD.Graph([way, relation]);
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('west');
graph = iD.actions.Reverse(way.id)(graph);
graph = iD.actionReverse(way.id)(graph);
expect(graph.entity(relation.id).members[0].role).to.eql('east');
});
});
+14 -14
View File
@@ -1,10 +1,10 @@
describe('iD.actions.Revert', function() {
describe('iD.actionRevert', function() {
describe('basic', function () {
it('removes a new entity', function() {
var n1 = iD.Node({id: 'n-1'}),
graph = iD.Graph().replace(n1);
graph = iD.actions.Revert('n-1')(graph);
graph = iD.actionRevert('n-1')(graph);
expect(graph.hasEntity('n-1')).to.be.undefined;
});
@@ -13,7 +13,7 @@ describe('iD.actions.Revert', function() {
n1up = n1.update({}),
graph = iD.Graph([n1]).replace(n1up);
graph = iD.actions.Revert('n1')(graph);
graph = iD.actionRevert('n1')(graph);
expect(graph.hasEntity('n1')).to.equal(n1);
});
@@ -21,7 +21,7 @@ describe('iD.actions.Revert', function() {
var n1 = iD.Node({id: 'n1'}),
graph = iD.Graph([n1]).remove(n1);
graph = iD.actions.Revert('n1')(graph);
graph = iD.actionRevert('n1')(graph);
expect(graph.hasEntity('n1')).to.equal(n1);
});
});
@@ -36,7 +36,7 @@ describe('iD.actions.Revert', function() {
w1up = w1.addNode('n-3', 2),
graph = iD.Graph([n1, n2, w1]).replace(n3).replace(w1up);
graph = iD.actions.Revert('n-3')(graph);
graph = iD.actionRevert('n-3')(graph);
var w1_1 = graph.hasEntity('w1');
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
@@ -54,7 +54,7 @@ describe('iD.actions.Revert', function() {
n1up = n1.update({}),
graph = iD.Graph([n1, n2, w1]).replace(n1up);
graph = iD.actions.Revert('n1')(graph);
graph = iD.actionRevert('n1')(graph);
var w1_1 = graph.hasEntity('w1');
expect(graph.hasEntity('n1'), 'n1 reverted').to.equal(n1);
@@ -73,7 +73,7 @@ describe('iD.actions.Revert', function() {
r1up = r1.addMember({id: 'n-2'}, 1),
graph = iD.Graph([n1, r1]).replace(n2).replace(r1up);
graph = iD.actions.Revert('n-2')(graph);
graph = iD.actionRevert('n-2')(graph);
var r1_1 = graph.hasEntity('r1');
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
@@ -89,7 +89,7 @@ describe('iD.actions.Revert', function() {
n1up = n1.update({}),
graph = iD.Graph([n1, n2, r1]).replace(n1up);
graph = iD.actions.Revert('n1')(graph);
graph = iD.actionRevert('n1')(graph);
var r1_1 = graph.hasEntity('r1');
expect(graph.hasEntity('n1'), 'n1 reverted').to.equal(n1);
@@ -107,7 +107,7 @@ describe('iD.actions.Revert', function() {
w1 = iD.Way({id: 'w-1', nodes: ['n1', 'n-2']}),
graph = iD.Graph([n1]).replace(n2).replace(w1);
graph = iD.actions.Revert('w-1')(graph);
graph = iD.actionRevert('w-1')(graph);
expect(graph.hasEntity('w-1'), 'w-1 removed').to.be.undefined;
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
@@ -122,7 +122,7 @@ describe('iD.actions.Revert', function() {
w1up = w1.addNode('n-2', 1),
graph = iD.Graph([n1, w1]).replace(n2).replace(w1up);
graph = iD.actions.Revert('w1')(graph);
graph = iD.actionRevert('w1')(graph);
expect(graph.hasEntity('w1'), 'w1 reverted').to.equal(w1);
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
@@ -137,7 +137,7 @@ describe('iD.actions.Revert', function() {
w1up = w1.addNode('n-2', 1),
graph = iD.Graph([n1, w1]).replace(n2).replace(w1up).remove(w1up);
graph = iD.actions.Revert('w1')(graph);
graph = iD.actionRevert('w1')(graph);
expect(graph.hasEntity('w1'), 'w1 reverted').to.equal(w1);
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
@@ -153,7 +153,7 @@ describe('iD.actions.Revert', function() {
r1 = iD.Relation({id: 'r-1', members: [{id: 'n1'}, {id: 'n-2'}]}),
graph = iD.Graph([n1]).replace(n2).replace(r1);
graph = iD.actions.Revert('r-1')(graph);
graph = iD.actionRevert('r-1')(graph);
expect(graph.hasEntity('r-1'), 'r-1 removed').to.be.undefined;
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
@@ -168,7 +168,7 @@ describe('iD.actions.Revert', function() {
r1up = r1.addMember({id: 'n-2'}, 1),
graph = iD.Graph([n1, r1]).replace(n2).replace(r1up);
graph = iD.actions.Revert('r1')(graph);
graph = iD.actionRevert('r1')(graph);
expect(graph.hasEntity('r1'), 'r1 reverted').to.equal(r1);
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
@@ -183,7 +183,7 @@ describe('iD.actions.Revert', function() {
r1up = r1.addMember({id: 'n-2'}, 1),
graph = iD.Graph([n1, r1]).replace(n2).replace(r1up).remove(r1up);
graph = iD.actions.Revert('r1')(graph);
graph = iD.actionRevert('r1')(graph);
expect(graph.hasEntity('r1'), 'r1 reverted').to.equal(r1);
expect(graph.hasEntity('n1'), 'n1 unchanged').to.equal(n1);
expect(graph.hasEntity('n-2'), 'n-2 unchanged').to.equal(n2);
+31 -31
View File
@@ -1,8 +1,8 @@
describe('iD.actions.Split', function () {
describe('iD.actionSplit', function () {
beforeEach(function () {
iD.areaKeys = iD.Context(window)
.presets(iD.data.presets).presets().areaKeys();
.presets(iD.dataPresets).presets().areaKeys();
});
describe('#disabled', function () {
@@ -14,7 +14,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c']})
]);
expect(iD.actions.Split('b').disabled(graph)).not.to.be.ok;
expect(iD.actionSplit('b').disabled(graph)).not.to.be.ok;
});
it('returns falsy for an intersection of two ways', function () {
@@ -28,7 +28,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['c', '*', 'd']})
]);
expect(iD.actions.Split('*').disabled(graph)).not.to.be.ok;
expect(iD.actionSplit('*').disabled(graph)).not.to.be.ok;
});
it('returns falsy for an intersection of two ways with parent way specified', function () {
@@ -42,7 +42,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['c', '*', 'd']})
]);
expect(iD.actions.Split('*').limitWays(['-']).disabled(graph)).not.to.be.ok;
expect(iD.actionSplit('*').limitWays(['-']).disabled(graph)).not.to.be.ok;
});
it('returns falsy for a self-intersection', function () {
@@ -54,7 +54,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']})
]);
expect(iD.actions.Split('a').disabled(graph)).not.to.be.ok;
expect(iD.actionSplit('a').disabled(graph)).not.to.be.ok;
});
it('returns \'not_eligible\' for the first node of a single way', function () {
@@ -64,7 +64,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b']})
]);
expect(iD.actions.Split('a').disabled(graph)).to.equal('not_eligible');
expect(iD.actionSplit('a').disabled(graph)).to.equal('not_eligible');
});
it('returns \'not_eligible\' for the last node of a single way', function () {
@@ -74,7 +74,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b']})
]);
expect(iD.actions.Split('b').disabled(graph)).to.equal('not_eligible');
expect(iD.actionSplit('b').disabled(graph)).to.equal('not_eligible');
});
it('returns \'not_eligible\' for an intersection of two ways with non-parent way specified', function () {
@@ -88,7 +88,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['c', '*', 'd']})
]);
expect(iD.actions.Split('*').limitWays(['-', '=']).disabled(graph)).to.equal('not_eligible');
expect(iD.actionSplit('*').limitWays(['-', '=']).disabled(graph)).to.equal('not_eligible');
});
});
@@ -108,7 +108,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c']})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
expect(graph.entity('=').nodes).to.eql(['b', 'c']);
@@ -123,7 +123,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c'], tags: tags})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
// Immutable tags => should be shared by identity.
expect(graph.entity('-').tags).to.equal(tags);
@@ -152,7 +152,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['d', 'b']})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
expect(graph.entity('=').nodes).to.eql(['b', 'c']);
@@ -186,7 +186,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['c', '*', 'd']})
]);
graph = iD.actions.Split('*', ['=', '¦'])(graph);
graph = iD.actionSplit('*', ['=', '¦'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', '*']);
expect(graph.entity('=').nodes).to.eql(['*', 'b']);
@@ -205,17 +205,17 @@ describe('iD.actions.Split', function () {
iD.Way({id: '|', nodes: ['c', '*', 'd']})
]);
var g1 = iD.actions.Split('*', ['=']).limitWays(['-'])(graph);
var g1 = iD.actionSplit('*', ['=']).limitWays(['-'])(graph);
expect(g1.entity('-').nodes).to.eql(['a', '*']);
expect(g1.entity('=').nodes).to.eql(['*', 'b']);
expect(g1.entity('|').nodes).to.eql(['c', '*', 'd']);
var g2 = iD.actions.Split('*', ['¦']).limitWays(['|'])(graph);
var g2 = iD.actionSplit('*', ['¦']).limitWays(['|'])(graph);
expect(g2.entity('-').nodes).to.eql(['a', '*', 'b']);
expect(g2.entity('|').nodes).to.eql(['c', '*']);
expect(g2.entity('¦').nodes).to.eql(['*', 'd']);
var g3 = iD.actions.Split('*', ['=', '¦']).limitWays(['-', '|'])(graph);
var g3 = iD.actionSplit('*', ['=', '¦']).limitWays(['-', '|'])(graph);
expect(g3.entity('-').nodes).to.eql(['a', '*']);
expect(g3.entity('=').nodes).to.eql(['*', 'b']);
expect(g3.entity('|').nodes).to.eql(['c', '*']);
@@ -245,7 +245,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'a', 'd']})
]);
graph = iD.actions.Split('a', ['='])(graph);
graph = iD.actionSplit('a', ['='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c', 'a']);
expect(graph.entity('=').nodes).to.eql(['a', 'd']);
@@ -272,19 +272,19 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
]);
var g1 = iD.actions.Split('a', ['='])(graph);
var g1 = iD.actionSplit('a', ['='])(graph);
expect(g1.entity('-').nodes).to.eql(['a', 'b', 'c']);
expect(g1.entity('=').nodes).to.eql(['c', 'd', 'a']);
var g2 = iD.actions.Split('b', ['='])(graph);
var g2 = iD.actionSplit('b', ['='])(graph);
expect(g2.entity('-').nodes).to.eql(['b', 'c', 'd']);
expect(g2.entity('=').nodes).to.eql(['d', 'a', 'b']);
var g3 = iD.actions.Split('c', ['='])(graph);
var g3 = iD.actionSplit('c', ['='])(graph);
expect(g3.entity('-').nodes).to.eql(['c', 'd', 'a']);
expect(g3.entity('=').nodes).to.eql(['a', 'b', 'c']);
var g4 = iD.actions.Split('d', ['='])(graph);
var g4 = iD.actionSplit('d', ['='])(graph);
expect(g4.entity('-').nodes).to.eql(['d', 'a', 'b']);
expect(g4.entity('=').nodes).to.eql(['b', 'c', 'd']);
});
@@ -298,7 +298,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '-', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']})
]);
graph = iD.actions.Split('a', ['='])(graph);
graph = iD.actionSplit('a', ['='])(graph);
expect(graph.entity('-').tags).to.eql({});
expect(graph.entity('=').tags).to.eql({});
expect(graph.parentRelations(graph.entity('-'))).to.have.length(1);
@@ -320,7 +320,7 @@ describe('iD.actions.Split', function () {
iD.Way({id: '=', nodes: ['a', 'b', 'c', 'a'], tags: {area: 'yes'}})
]);
graph = iD.actions.Split('b', ['~'])(graph);
graph = iD.actionSplit('b', ['~'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
expect(graph.entity('~').nodes).to.eql(['b', 'c']);
@@ -347,7 +347,7 @@ describe('iD.actions.Split', function () {
iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'forward'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('r').members).to.eql([
{id: '-', type: 'way', role: 'forward'},
@@ -376,7 +376,7 @@ describe('iD.actions.Split', function () {
iD.Relation({id: 'r', members: [{id: '-', type: 'way'}, {id: '~', type: 'way'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['-', '=', '~']);
});
@@ -402,7 +402,7 @@ describe('iD.actions.Split', function () {
iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
});
@@ -416,7 +416,7 @@ describe('iD.actions.Split', function () {
iD.Relation({id: 'r', members: [{id: '~', type: 'way'}, {id: '-', type: 'way'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
});
@@ -430,7 +430,7 @@ describe('iD.actions.Split', function () {
iD.Relation({id: 'r', members: [{id: '-', type: 'way', role: 'outer'}], tags: {type: 'multipolygon'}})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('-').tags).to.eql({});
expect(graph.entity('r').tags).to.eql({type: 'multipolygon', natural: 'water'});
@@ -462,7 +462,7 @@ describe('iD.actions.Split', function () {
{id: 'c', role: 'via'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('r').members).to.eql([
{id: '=', role: 'from'},
@@ -494,7 +494,7 @@ describe('iD.actions.Split', function () {
{id: 'c', role: 'via'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('r').members).to.eql([
{id: '~', role: 'from'},
@@ -526,7 +526,7 @@ describe('iD.actions.Split', function () {
{id: 'c', role: 'via'}]})
]);
graph = iD.actions.Split('b', ['='])(graph);
graph = iD.actionSplit('b', ['='])(graph);
expect(graph.entity('r').members).to.eql([
{id: '-', role: 'from'},
+7 -7
View File
@@ -1,4 +1,4 @@
describe('iD.actions.Straighten', function () {
describe('iD.actionStraighten', function () {
var projection = d3.geoMercator();
describe('#disabled', function () {
@@ -11,7 +11,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd']})
]);
expect(iD.actions.Straighten('-', projection).disabled(graph)).not.to.be.ok;
expect(iD.actionStraighten('-', projection).disabled(graph)).not.to.be.ok;
});
it('returns \'too_bendy\' for ways with internal nodes far off centerline', function () {
@@ -23,7 +23,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd']})
]);
expect(iD.actions.Straighten('-', projection).disabled(graph)).to.equal('too_bendy');
expect(iD.actionStraighten('-', projection).disabled(graph)).to.equal('too_bendy');
});
it('returns \'too_bendy\' for ways with coincident start/end nodes', function () {
@@ -35,7 +35,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd']})
]);
expect(iD.actions.Straighten('-', projection).disabled(graph)).to.equal('too_bendy');
expect(iD.actionStraighten('-', projection).disabled(graph)).to.equal('too_bendy');
});
});
@@ -47,7 +47,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c']})
]);
graph = iD.actions.Straighten('-', projection)(graph);
graph = iD.actionStraighten('-', projection)(graph);
expect(graph.hasEntity('b')).to.eq(undefined);
});
@@ -60,7 +60,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '-', nodes: ['a', 'b', 'c']})
]);
graph = iD.actions.Straighten('-', projection)(graph);
graph = iD.actionStraighten('-', projection)(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c']);
});
@@ -75,7 +75,7 @@ describe('iD.actions.Straighten', function () {
iD.Way({id: '=', nodes: ['b']})
]);
graph = iD.actions.Straighten('-', projection)(graph);
graph = iD.actionStraighten('-', projection)(graph);
expect(graph.entity('-').nodes).to.have.length(3);
});
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.actions.UnrestrictTurn', function() {
describe('iD.actionUnrestrictTurn', function() {
it('removes a restriction from a restricted turn', function() {
// u====*--->w
var graph = iD.Graph([
@@ -13,7 +13,7 @@ describe('iD.actions.UnrestrictTurn', function() {
{id: '*', role: 'via', type: 'node'}
]})
]),
action = iD.actions.UnrestrictTurn({
action = iD.actionUnrestrictTurn({
restriction: 'r'
});
+3 -3
View File
@@ -1,17 +1,17 @@
describe('iD.behavior.Hash', function () {
describe('iD.behaviorHash', function () {
mocha.globals('__onhashchange.hash');
var hash, context;
beforeEach(function () {
context = iD.Context(window)
.imagery(iD.data.imagery);
.imagery(iD.dataImagery);
context.container(d3.select(document.createElement('div')));
// Neuter connection
context.connection().loadTiles = function () {};
hash = iD.behavior.Hash(context);
hash = iD.behaviorHash(context);
d3.select(document.createElement('div'))
.call(context.map());
+10 -10
View File
@@ -1,4 +1,4 @@
describe('iD.behavior.Hover', function() {
describe('iD.behaviorHover', function() {
var container, context;
beforeEach(function() {
@@ -15,7 +15,7 @@ describe('iD.behavior.Hover', function() {
describe('#off', function () {
it('removes the .hover class from all elements', function () {
container.append('span').attr('class', 'hover');
container.call(iD.behavior.Hover(context).off);
container.call(iD.behaviorHover(context).off);
expect(container.select('span')).not.to.be.classed('hover');
});
});
@@ -29,8 +29,8 @@ describe('iD.behavior.Hover', function() {
.data([a, b, a, b])
.enter().append('span').attr('class', function(d) { return d.id; });
container.call(iD.behavior.Hover(context));
iD.util.triggerEvent(container.selectAll('.a'), 'mouseover');
container.call(iD.behaviorHover(context));
iD.utilTriggerEvent(container.selectAll('.a'), 'mouseover');
expect(container.selectAll('.a.hover').nodes()).to.have.length(2);
expect(container.selectAll('.b.hover').nodes()).to.have.length(0);
@@ -41,8 +41,8 @@ describe('iD.behavior.Hover', function() {
.data([iD.Relation({id: 'a', members: [{id: 'b'}]}), iD.Node({id: 'b'})])
.enter().append('span').attr('class', function(d) { return d.id; });
container.call(iD.behavior.Hover(context));
iD.util.triggerEvent(container.selectAll('.a'), 'mouseover');
container.call(iD.behaviorHover(context));
iD.utilTriggerEvent(container.selectAll('.a'), 'mouseover');
expect(container.selectAll('.a.hover').nodes()).to.have.length(1);
expect(container.selectAll('.b.hover').nodes()).to.have.length(1);
@@ -53,8 +53,8 @@ describe('iD.behavior.Hover', function() {
it('removes the .hover class from all elements', function () {
container.append('span').attr('class', 'hover');
container.call(iD.behavior.Hover(context));
iD.util.triggerEvent(container.selectAll('.hover'), 'mouseout');
container.call(iD.behaviorHover(context));
iD.utilTriggerEvent(container.selectAll('.hover'), 'mouseout');
expect(container.selectAll('.hover').nodes()).to.have.length(0);
});
@@ -64,7 +64,7 @@ describe('iD.behavior.Hover', function() {
it('replaces the .hover class with .hover-suppressed', function () {
container.append('span').attr('class', 'hover');
container.call(iD.behavior.Hover(context).altDisables(true));
container.call(iD.behaviorHover(context).altDisables(true));
happen.keydown(window, {keyCode: 18});
expect(container.selectAll('.hover').nodes()).to.have.length(0);
@@ -76,7 +76,7 @@ describe('iD.behavior.Hover', function() {
it('replaces the .hover-suppressed class with .hover', function () {
container.append('span').attr('class', 'hover-suppressed');
container.call(iD.behavior.Hover(context).altDisables(true));
container.call(iD.behaviorHover(context).altDisables(true));
happen.keyup(window, {keyCode: 18});
expect(container.selectAll('.hover').nodes()).to.have.length(1);
+3 -3
View File
@@ -1,14 +1,14 @@
describe('iD.behavior.Lasso', function () {
describe('iD.behaviorLasso', function () {
var lasso, context;
beforeEach(function () {
context = iD.Context(window).imagery(iD.data.imagery);
context = iD.Context(window).imagery(iD.dataImagery);
context.container(d3.select(document.createElement('div')));
// Neuter connection
context.connection().loadTiles = function () {};
lasso = iD.behavior.Lasso(context);
lasso = iD.behaviorLasso(context);
d3.select(document.createElement('div'))
.call(context.map());
+10 -10
View File
@@ -1,14 +1,14 @@
describe('iD.behavior.Select', function() {
describe('iD.behaviorSelect', function() {
var a, b, context, behavior, container;
beforeEach(function() {
container = d3.select('body').append('div');
context = iD.Context(window).imagery(iD.data.imagery).container(container);
context = iD.Context(window).imagery(iD.dataImagery).container(container);
a = iD.Node({loc: [0, 0]});
b = iD.Node({loc: [0, 0]});
context.perform(iD.actions.AddEntity(a), iD.actions.AddEntity(b));
context.perform(iD.actionAddEntity(a), iD.actionAddEntity(b));
container.call(context.map())
.append('div')
@@ -19,9 +19,9 @@ describe('iD.behavior.Select', function() {
.enter().append('circle')
.attr('class', function(d) { return d.id; });
context.enter(iD.modes.Browse(context));
context.enter(iD.modeBrowse(context));
behavior = iD.behavior.Select(context);
behavior = iD.behaviorSelect(context);
context.install(behavior);
});
@@ -37,31 +37,31 @@ describe('iD.behavior.Select', function() {
});
specify('click on empty space clears the selection', function() {
context.enter(iD.modes.Select(context, [a.id]));
context.enter(iD.modeSelect(context, [a.id]));
happen.click(context.surface().node());
expect(context.mode().id).to.eql('browse');
});
specify('shift-click on unselected entity adds it to the selection', function() {
context.enter(iD.modes.Select(context, [a.id]));
context.enter(iD.modeSelect(context, [a.id]));
happen.click(context.surface().selectAll('.' + b.id).node(), {shiftKey: true});
expect(context.selectedIDs()).to.eql([a.id, b.id]);
});
specify('shift-click on selected entity removes it from the selection', function() {
context.enter(iD.modes.Select(context, [a.id, b.id]));
context.enter(iD.modeSelect(context, [a.id, b.id]));
happen.click(context.surface().selectAll('.' + b.id).node(), {shiftKey: true});
expect(context.selectedIDs()).to.eql([a.id]);
});
specify('shift-click on last selected entity clears the selection', function() {
context.enter(iD.modes.Select(context, [a.id]));
context.enter(iD.modeSelect(context, [a.id]));
happen.click(context.surface().selectAll('.' + a.id).node(), {shiftKey: true});
expect(context.mode().id).to.eql('browse');
});
specify('shift-click on empty space leaves the selection unchanged', function() {
context.enter(iD.modes.Select(context, [a.id]));
context.enter(iD.modeSelect(context, [a.id]));
happen.click(context.surface().node(), {shiftKey: true});
expect(context.selectedIDs()).to.eql([a.id]);
});
+5 -5
View File
@@ -274,8 +274,8 @@ describe('iD.History', function () {
describe('#toJSON', function() {
it('doesn\'t generate unsaveable changes', function() {
var node_1 = iD.Node({id: 'n-1'});
history.perform(iD.actions.AddEntity(node_1));
history.perform(iD.actions.DeleteNode('n-1'));
history.perform(iD.actionAddEntity(node_1));
history.perform(iD.actionDeleteNode('n-1'));
expect(history.toJSON()).to.be.not.ok;
});
@@ -285,9 +285,9 @@ describe('iD.History', function () {
node2 = iD.Node({id: 'n2'}),
node3 = iD.Node({id: 'n3'});
history.merge([node1, node2, node3]);
history.perform(iD.actions.AddEntity(node_1)); // addition
history.perform(iD.actions.ChangeTags('n2', {k: 'v'})); // modification
history.perform(iD.actions.DeleteNode('n3')); // deletion
history.perform(iD.actionAddEntity(node_1)); // addition
history.perform(iD.actionChangeTags('n2', {k: 'v'})); // modification
history.perform(iD.actionDeleteNode('n3')); // deletion
var json = JSON.parse(history.toJSON());
expect(json.version).to.eql(3);
expect( _.isEqual(json.entities, [node_1, node2.update({tags: {k: 'v'}})]) ).to.be.ok;
+1 -1
View File
@@ -133,7 +133,7 @@ describe('iD.Relation', function () {
it('does not error on self-referencing relations', function () {
var r = iD.Relation();
r = r.addMember({id: r.id});
expect(r.extent(iD.Graph([r]))).to.eql(iD.geo.Extent());
expect(r.extent(iD.Graph([r]))).to.eql(iD.geoExtent());
});
});
+18 -18
View File
@@ -8,14 +8,14 @@ describe('iD.Tree', function() {
graph.rebase([node], [graph]);
tree.rebase([node]);
expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), graph)).to.eql([node]);
expect(tree.intersects(iD.geoExtent([0, 0], [2, 2]), graph)).to.eql([node]);
});
it('is idempotent', function() {
var graph = iD.Graph(),
tree = iD.Tree(graph),
node = iD.Node({id: 'n', loc: [1, 1]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph.rebase([node], [graph]);
tree.rebase([node]);
@@ -33,13 +33,13 @@ describe('iD.Tree', function() {
node_ = node.update({loc: [10, 10]}),
g = graph.replace(node_);
expect(tree.intersects(iD.geo.Extent([9, 9], [11, 11]), g)).to.eql([node_]);
expect(tree.intersects(iD.geoExtent([9, 9], [11, 11]), g)).to.eql([node_]);
graph.rebase([node], [graph]);
tree.rebase([node]);
expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), g)).to.eql([]);
expect(tree.intersects(iD.geo.Extent([0, 0], [11, 11]), g)).to.eql([node_]);
expect(tree.intersects(iD.geoExtent([0, 0], [2, 2]), g)).to.eql([]);
expect(tree.intersects(iD.geoExtent([0, 0], [11, 11]), g)).to.eql([node_]);
});
it('does not error on self-referencing relations', function() {
@@ -54,7 +54,7 @@ describe('iD.Tree', function() {
graph.rebase([node, relation], [graph]);
tree.rebase([relation]);
expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), graph)).to.eql([relation]);
expect(tree.intersects(iD.geoExtent([0, 0], [2, 2]), graph)).to.eql([relation]);
});
it('adjusts entities that are force-rebased', function() {
@@ -69,7 +69,7 @@ describe('iD.Tree', function() {
graph.rebase([node], [graph], true);
tree.rebase([node], true);
expect(tree.intersects(iD.geo.Extent([0, 0], [2, 2]), graph)).to.eql([]);
expect(tree.intersects(iD.geoExtent([0, 0], [2, 2]), graph)).to.eql([]);
});
});
@@ -79,7 +79,7 @@ describe('iD.Tree', function() {
tree = iD.Tree(graph),
n1 = iD.Node({loc: [1, 1]}),
n2 = iD.Node({loc: [3, 3]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(n1).replace(n2);
expect(tree.intersects(extent, graph)).to.eql([n1]);
@@ -91,7 +91,7 @@ describe('iD.Tree', function() {
n1 = iD.Node({id: 'n1', loc: [0, 0]}),
n2 = iD.Node({id: 'n2', loc: [1, 1]}),
relation = iD.Relation({id: 'r', members: [{id: 'n1'}, {id: 'n2'}]}),
extent = iD.geo.Extent([0.5, 0.5], [1.5, 1.5]);
extent = iD.geoExtent([0.5, 0.5], [1.5, 1.5]);
graph.rebase([relation, n1], [graph]);
tree.rebase([relation, n1]);
@@ -109,7 +109,7 @@ describe('iD.Tree', function() {
node = iD.Node({id: 'n', loc: [0.5, 0.5]}),
way = iD.Way({nodes: ['n']}),
graph = base.replace(way),
extent = iD.geo.Extent([0, 0], [1, 1]);
extent = iD.geoExtent([0, 0], [1, 1]);
expect(tree.intersects(extent, graph)).to.eql([]);
@@ -123,7 +123,7 @@ describe('iD.Tree', function() {
tree = iD.Tree(graph),
node = iD.Node({id: 'n', loc: [1, 1]}),
way = iD.Way({nodes: ['n']}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(node).replace(way);
expect(tree.intersects(extent, graph)).to.eql([node, way]);
@@ -137,7 +137,7 @@ describe('iD.Tree', function() {
tree = iD.Tree(graph),
node = iD.Node({id: 'n', loc: [1, 1]}),
relation = iD.Relation({members: [{type: 'node', id: 'n'}]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(node).replace(relation);
expect(tree.intersects(extent, graph)).to.eql([node, relation]);
@@ -152,7 +152,7 @@ describe('iD.Tree', function() {
node = iD.Node({id: 'n', loc: [1, 1]}),
way = iD.Way({id: 'w', nodes: ['n']}),
relation = iD.Relation({members: [{type: 'multipolygon', id: 'w'}]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(node).replace(way).replace(relation);
expect(tree.intersects(extent, graph)).to.eql([node, way, relation]);
@@ -167,7 +167,7 @@ describe('iD.Tree', function() {
n1 = iD.Node({id: 'n1', loc: [1, 1]}),
n2 = iD.Node({id: 'n2', loc: [3, 3]}),
way = iD.Way({nodes: ['n1', 'n2']}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(n1).replace(n2).replace(way);
expect(tree.intersects(extent, graph)).to.eql([n1, way]);
@@ -183,7 +183,7 @@ describe('iD.Tree', function() {
n1 = iD.Node({id: 'n1', loc: [1, 1]}),
n2 = iD.Node({id: 'n2', loc: [3, 3]}),
way = iD.Way({nodes: ['n1', 'n2']}),
extent = iD.geo.Extent([0, 0], [4, 4]);
extent = iD.geoExtent([0, 0], [4, 4]);
graph = graph.replace(n1).replace(n2).replace(way);
expect(tree.intersects(extent, graph)).to.eql([n1, n2, way]);
@@ -200,7 +200,7 @@ describe('iD.Tree', function() {
var graph = iD.Graph(),
tree = iD.Tree(graph),
node = iD.Node({loc: [1, 1]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
graph = graph.replace(node);
expect(tree.intersects(extent, graph)).to.eql([node]);
@@ -213,7 +213,7 @@ describe('iD.Tree', function() {
var base = iD.Graph(),
tree = iD.Tree(base),
node = iD.Node({id: 'n', loc: [1, 1]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
var graph = base.replace(node).remove(node);
expect(tree.intersects(extent, graph)).to.eql([]);
@@ -229,7 +229,7 @@ describe('iD.Tree', function() {
node = iD.Node({id: 'n', loc: [1, 1]}),
r1 = iD.Relation({id: 'r1', members: [{id: 'n'}]}),
r2 = iD.Relation({id: 'r2', members: [{id: 'r1'}]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
extent = iD.geoExtent([0, 0], [2, 2]);
var graph = base.replace(r1).replace(r2);
expect(tree.intersects(extent, graph)).to.eql([]);
+74 -74
View File
@@ -1,55 +1,55 @@
describe('iD.geo.Extent', function () {
describe('iD.geoExtent', function () {
describe('constructor', function () {
it('defaults to infinitely empty extent', function () {
expect(iD.geo.Extent().equals([[Infinity, Infinity], [-Infinity, -Infinity]])).to.be.ok;
expect(iD.geoExtent().equals([[Infinity, Infinity], [-Infinity, -Infinity]])).to.be.ok;
});
it('constructs via a point', function () {
var p = [0, 0];
expect(iD.geo.Extent(p).equals([p, p])).to.be.ok;
expect(iD.geoExtent(p).equals([p, p])).to.be.ok;
});
it('constructs via two points', function () {
var min = [0, 0],
max = [5, 10];
expect(iD.geo.Extent(min, max).equals([min, max])).to.be.ok;
expect(iD.geoExtent(min, max).equals([min, max])).to.be.ok;
});
it('constructs via an extent', function () {
var min = [0, 0],
max = [5, 10];
expect(iD.geo.Extent([min, max]).equals([min, max])).to.be.ok;
expect(iD.geoExtent([min, max]).equals([min, max])).to.be.ok;
});
it('constructs via an iD.geo.Extent', function () {
it('constructs via an iD.geoExtent', function () {
var min = [0, 0],
max = [5, 10],
extent = iD.geo.Extent(min, max);
expect(iD.geo.Extent(extent).equals(extent)).to.be.ok;
extent = iD.geoExtent(min, max);
expect(iD.geoExtent(extent).equals(extent)).to.be.ok;
});
it('has length 2', function () {
expect(iD.geo.Extent().length).to.equal(2);
expect(iD.geoExtent().length).to.equal(2);
});
it('has min element', function () {
var min = [0, 0],
max = [5, 10];
expect(iD.geo.Extent(min, max)[0]).to.equal(min);
expect(iD.geoExtent(min, max)[0]).to.equal(min);
});
it('has max element', function () {
var min = [0, 0],
max = [5, 10];
expect(iD.geo.Extent(min, max)[1]).to.equal(max);
expect(iD.geoExtent(min, max)[1]).to.equal(max);
});
});
describe('#equals', function () {
it('tests extent equality', function () {
var e1 = iD.geo.Extent([0, 0], [10, 10]),
e2 = iD.geo.Extent([0, 0], [10, 10]),
e3 = iD.geo.Extent([0, 0], [12, 12]);
var e1 = iD.geoExtent([0, 0], [10, 10]),
e2 = iD.geoExtent([0, 0], [10, 10]),
e3 = iD.geoExtent([0, 0], [12, 12]);
expect(e1.equals(e2)).to.be.ok;
expect(e1.equals(e3)).to.be.not.ok;
});
@@ -57,66 +57,66 @@ describe('iD.geo.Extent', function () {
describe('#center', function () {
it('returns the center point', function () {
expect(iD.geo.Extent([0, 0], [5, 10]).center()).to.eql([2.5, 5]);
expect(iD.geoExtent([0, 0], [5, 10]).center()).to.eql([2.5, 5]);
});
});
describe('#rectangle', function () {
it('returns the extent as a rectangle', function () {
expect(iD.geo.Extent([0, 0], [5, 10]).rectangle()).to.eql([0, 0, 5, 10]);
expect(iD.geoExtent([0, 0], [5, 10]).rectangle()).to.eql([0, 0, 5, 10]);
});
});
describe('#polygon', function () {
it('returns the extent as a polygon', function () {
expect(iD.geo.Extent([0, 0], [5, 10]).polygon())
expect(iD.geoExtent([0, 0], [5, 10]).polygon())
.to.eql([[0, 0], [0, 10], [5, 10], [5, 0], [0, 0]]);
});
});
describe('#area', function () {
it('returns the area', function () {
expect(iD.geo.Extent([0, 0], [5, 10]).area()).to.eql(50);
expect(iD.geoExtent([0, 0], [5, 10]).area()).to.eql(50);
});
});
describe('#padByMeters', function () {
it('does not change centerpoint of an extent', function () {
var min = [0, 0], max = [5, 10];
expect(iD.geo.Extent(min, max).padByMeters(100).center()).to.eql([2.5, 5]);
expect(iD.geoExtent(min, max).padByMeters(100).center()).to.eql([2.5, 5]);
});
it('does not affect the extent with a pad of zero', function () {
var min = [0, 0], max = [5, 10];
expect(iD.geo.Extent(min, max).padByMeters(0)[0]).to.eql([0, 0]);
expect(iD.geoExtent(min, max).padByMeters(0)[0]).to.eql([0, 0]);
});
});
describe('#extend', function () {
it('does not modify self', function () {
var extent = iD.geo.Extent([0, 0], [0, 0]);
var extent = iD.geoExtent([0, 0], [0, 0]);
extent.extend([1, 1]);
expect(extent.equals([[0, 0], [0, 0]])).to.be.ok;
});
it('returns the minimal extent containing self and the given point', function () {
expect(iD.geo.Extent().extend([0, 0]).equals([[0, 0], [0, 0]])).to.be.ok;
expect(iD.geo.Extent([0, 0], [0, 0]).extend([5, 10]).equals([[0, 0], [5, 10]])).to.be.ok;
expect(iD.geoExtent().extend([0, 0]).equals([[0, 0], [0, 0]])).to.be.ok;
expect(iD.geoExtent([0, 0], [0, 0]).extend([5, 10]).equals([[0, 0], [5, 10]])).to.be.ok;
});
it('returns the minimal extent containing self and the given extent', function () {
expect(iD.geo.Extent().extend([[0, 0], [5, 10]]).equals([[0, 0], [5, 10]])).to.be.ok;
expect(iD.geo.Extent([0, 0], [0, 0]).extend([[4, -1], [5, 10]]).equals([[0, -1], [5, 10]])).to.be.ok;
expect(iD.geoExtent().extend([[0, 0], [5, 10]]).equals([[0, 0], [5, 10]])).to.be.ok;
expect(iD.geoExtent([0, 0], [0, 0]).extend([[4, -1], [5, 10]]).equals([[0, -1], [5, 10]])).to.be.ok;
});
});
describe('#_extend', function () {
it('extends self to the minimal extent containing self and the given extent', function () {
var e = iD.geo.Extent();
var e = iD.geoExtent();
e._extend([[0, 0], [5, 10]]);
expect(e.equals([[0, 0], [5, 10]])).to.be.ok;
e = iD.geo.Extent([0, 0], [0, 0]);
e = iD.geoExtent([0, 0], [0, 0]);
e._extend([[4, -1], [5, 10]]);
expect(e.equals([[0, -1], [5, 10]])).to.be.ok;
});
@@ -124,123 +124,123 @@ describe('iD.geo.Extent', function () {
describe('#contains', function () {
it('returns true for a point inside self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([2, 2])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).contains([2, 2])).to.be.true;
});
it('returns true for a point on the boundary of self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([0, 0])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).contains([0, 0])).to.be.true;
});
it('returns false for a point outside self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([6, 6])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).contains([6, 6])).to.be.false;
});
it('returns true for an extent contained by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([[1, 1], [2, 2]])).to.be.true;
expect(iD.geo.Extent([1, 1], [2, 2]).contains([[0, 0], [5, 5]])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).contains([[1, 1], [2, 2]])).to.be.true;
expect(iD.geoExtent([1, 1], [2, 2]).contains([[0, 0], [5, 5]])).to.be.false;
});
it('returns false for an extent partially contained by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([[1, 1], [6, 6]])).to.be.false;
expect(iD.geo.Extent([1, 1], [6, 6]).contains([[0, 0], [5, 5]])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).contains([[1, 1], [6, 6]])).to.be.false;
expect(iD.geoExtent([1, 1], [6, 6]).contains([[0, 0], [5, 5]])).to.be.false;
});
it('returns false for an extent not intersected by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).contains([[6, 6], [7, 7]])).to.be.false;
expect(iD.geo.Extent([[6, 6], [7, 7]]).contains([[0, 0], [5, 5]])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).contains([[6, 6], [7, 7]])).to.be.false;
expect(iD.geoExtent([[6, 6], [7, 7]]).contains([[0, 0], [5, 5]])).to.be.false;
});
});
describe('#intersects', function () {
it('returns true for a point inside self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([2, 2])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([2, 2])).to.be.true;
});
it('returns true for a point on the boundary of self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([0, 0])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([0, 0])).to.be.true;
});
it('returns false for a point outside self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([6, 6])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([6, 6])).to.be.false;
});
it('returns true for an extent contained by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[1, 1], [2, 2]])).to.be.true;
expect(iD.geo.Extent([1, 1], [2, 2]).intersects([[0, 0], [5, 5]])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([[1, 1], [2, 2]])).to.be.true;
expect(iD.geoExtent([1, 1], [2, 2]).intersects([[0, 0], [5, 5]])).to.be.true;
});
it('returns true for an extent partially contained by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[1, 1], [6, 6]])).to.be.true;
expect(iD.geo.Extent([1, 1], [6, 6]).intersects([[0, 0], [5, 5]])).to.be.true;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([[1, 1], [6, 6]])).to.be.true;
expect(iD.geoExtent([1, 1], [6, 6]).intersects([[0, 0], [5, 5]])).to.be.true;
});
it('returns false for an extent not intersected by self', function () {
expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[6, 6], [7, 7]])).to.be.false;
expect(iD.geo.Extent([[6, 6], [7, 7]]).intersects([[0, 0], [5, 5]])).to.be.false;
expect(iD.geoExtent([0, 0], [5, 5]).intersects([[6, 6], [7, 7]])).to.be.false;
expect(iD.geoExtent([[6, 6], [7, 7]]).intersects([[0, 0], [5, 5]])).to.be.false;
});
});
describe('#intersection', function () {
it('returns an empty extent if self does not intersect with other', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([6, 6], [7, 7]);
expect(a.intersection(b)).to.eql(iD.geo.Extent());
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([6, 6], [7, 7]);
expect(a.intersection(b)).to.eql(iD.geoExtent());
});
it('returns the intersection of self with other (1)', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([3, 4], [7, 7]);
expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 4], [5, 5]));
expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 4], [5, 5]));
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([3, 4], [7, 7]);
expect(a.intersection(b)).to.eql(iD.geoExtent([3, 4], [5, 5]));
expect(b.intersection(a)).to.eql(iD.geoExtent([3, 4], [5, 5]));
});
it('returns the intersection of self with other (2)', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([3, -4], [7, 2]);
expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 0], [5, 2]));
expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 0], [5, 2]));
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([3, -4], [7, 2]);
expect(a.intersection(b)).to.eql(iD.geoExtent([3, 0], [5, 2]));
expect(b.intersection(a)).to.eql(iD.geoExtent([3, 0], [5, 2]));
});
it('returns the intersection of self with other (3)', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([3, 3], [4, 7]);
expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 3], [4, 5]));
expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 3], [4, 5]));
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([3, 3], [4, 7]);
expect(a.intersection(b)).to.eql(iD.geoExtent([3, 3], [4, 5]));
expect(b.intersection(a)).to.eql(iD.geoExtent([3, 3], [4, 5]));
});
it('returns the intersection of self with other (4)', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([3, -2], [4, 2]);
expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 0], [4, 2]));
expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 0], [4, 2]));
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([3, -2], [4, 2]);
expect(a.intersection(b)).to.eql(iD.geoExtent([3, 0], [4, 2]));
expect(b.intersection(a)).to.eql(iD.geoExtent([3, 0], [4, 2]));
});
it('returns the intersection of self with other (5)', function () {
var a = iD.geo.Extent([0, 0], [5, 5]),
b = iD.geo.Extent([1, 1], [2, 2]);
expect(a.intersection(b)).to.eql(iD.geo.Extent([1, 1], [2, 2]));
expect(b.intersection(a)).to.eql(iD.geo.Extent([1, 1], [2, 2]));
var a = iD.geoExtent([0, 0], [5, 5]),
b = iD.geoExtent([1, 1], [2, 2]);
expect(a.intersection(b)).to.eql(iD.geoExtent([1, 1], [2, 2]));
expect(b.intersection(a)).to.eql(iD.geoExtent([1, 1], [2, 2]));
});
});
describe('#percentContainedIn', function () {
it('returns a 0 if self does not intersect other', function () {
var a = iD.geo.Extent([0, 0], [1, 1]),
b = iD.geo.Extent([0, 3], [4, 1]);
var a = iD.geoExtent([0, 0], [1, 1]),
b = iD.geoExtent([0, 3], [4, 1]);
expect(a.percentContainedIn(b)).to.eql(0);
expect(b.percentContainedIn(a)).to.eql(0);
});
it('returns the percent contained of self with other (1)', function () {
var a = iD.geo.Extent([0, 0], [2, 1]),
b = iD.geo.Extent([1, 0], [3, 1]);
var a = iD.geoExtent([0, 0], [2, 1]),
b = iD.geoExtent([1, 0], [3, 1]);
expect(a.percentContainedIn(b)).to.eql(0.5);
expect(b.percentContainedIn(a)).to.eql(0.5);
});
it('returns the percent contained of self with other (2)', function () {
var a = iD.geo.Extent([0, 0], [4, 1]),
b = iD.geo.Extent([3, 0], [4, 2]);
var a = iD.geoExtent([0, 0], [4, 1]),
b = iD.geoExtent([3, 0], [4, 2]);
expect(a.percentContainedIn(b)).to.eql(0.25);
expect(b.percentContainedIn(a)).to.eql(0.5);
});
+95 -95
View File
@@ -1,196 +1,196 @@
describe('iD.geo', function() {
describe('.roundCoords', function() {
describe('geoRoundCoords', function() {
it('rounds coordinates', function() {
expect(iD.geo.roundCoords([0.1, 1])).to.eql([0, 1]);
expect(iD.geo.roundCoords([0, 1])).to.eql([0, 1]);
expect(iD.geo.roundCoords([0, 1.1])).to.eql([0, 1]);
expect(iD.geoRoundCoords([0.1, 1])).to.eql([0, 1]);
expect(iD.geoRoundCoords([0, 1])).to.eql([0, 1]);
expect(iD.geoRoundCoords([0, 1.1])).to.eql([0, 1]);
});
});
describe('.interp', function() {
describe('geoInterp', function() {
it('interpolates halfway', function() {
var a = [0, 0],
b = [10, 10];
expect(iD.geo.interp(a, b, 0.5)).to.eql([5, 5]);
expect(iD.geoInterp(a, b, 0.5)).to.eql([5, 5]);
});
it('interpolates to one side', function() {
var a = [0, 0],
b = [10, 10];
expect(iD.geo.interp(a, b, 0)).to.eql([0, 0]);
expect(iD.geoInterp(a, b, 0)).to.eql([0, 0]);
});
});
describe('.cross', function() {
describe('geoCross', function() {
it('cross product of right hand turn is positive', function() {
var o = [0, 0],
a = [2, 0],
b = [0, 2];
expect(iD.geo.cross(o, a, b)).to.eql(4);
expect(iD.geoCross(o, a, b)).to.eql(4);
});
it('cross product of left hand turn is negative', function() {
var o = [0, 0],
a = [2, 0],
b = [0, -2];
expect(iD.geo.cross(o, a, b)).to.eql(-4);
expect(iD.geoCross(o, a, b)).to.eql(-4);
});
it('cross product of colinear points is zero', function() {
var o = [0, 0],
a = [-2, 0],
b = [2, 0];
expect(iD.geo.cross(o, a, b)).to.equal(0);
expect(iD.geoCross(o, a, b)).to.equal(0);
});
});
describe('.euclideanDistance', function() {
describe('geoEuclideanDistance', function() {
it('distance between two same points is zero', function() {
var a = [0, 0],
b = [0, 0];
expect(iD.geo.euclideanDistance(a, b)).to.eql(0);
expect(iD.geoEuclideanDistance(a, b)).to.eql(0);
});
it('a straight 10 unit line is 10', function() {
var a = [0, 0],
b = [10, 0];
expect(iD.geo.euclideanDistance(a, b)).to.eql(10);
expect(iD.geoEuclideanDistance(a, b)).to.eql(10);
});
it('a pythagorean triangle is right', function() {
var a = [0, 0],
b = [4, 3];
expect(iD.geo.euclideanDistance(a, b)).to.eql(5);
expect(iD.geoEuclideanDistance(a, b)).to.eql(5);
});
});
describe('.latToMeters', function() {
describe('geoLatToMeters', function() {
it('0 degrees latitude is 0 meters', function() {
expect(iD.geo.latToMeters(0)).to.eql(0);
expect(iD.geoLatToMeters(0)).to.eql(0);
});
it('1 degree latitude is approx 111 km', function() {
expect(iD.geo.latToMeters(1)).to.be.within(110E3, 112E3);
expect(iD.geoLatToMeters(1)).to.be.within(110E3, 112E3);
});
it('-1 degree latitude is approx -111 km', function() {
expect(iD.geo.latToMeters(-1)).to.be.within(-112E3, -110E3);
expect(iD.geoLatToMeters(-1)).to.be.within(-112E3, -110E3);
});
});
describe('.lonToMeters', function() {
describe('geoLonToMeters', function() {
it('0 degrees longitude is 0 km', function() {
expect(iD.geo.lonToMeters(0, 0)).to.eql(0);
expect(iD.geoLonToMeters(0, 0)).to.eql(0);
});
it('distance of 1 degree longitude varies with latitude', function() {
expect(iD.geo.lonToMeters(1, 0)).to.be.within(110E3, 112E3);
expect(iD.geo.lonToMeters(1, 15)).to.be.within(107E3, 108E3);
expect(iD.geo.lonToMeters(1, 30)).to.be.within(96E3, 97E3);
expect(iD.geo.lonToMeters(1, 45)).to.be.within(78E3, 79E3);
expect(iD.geo.lonToMeters(1, 60)).to.be.within(55E3, 56E3);
expect(iD.geo.lonToMeters(1, 75)).to.be.within(28E3, 29E3);
expect(iD.geo.lonToMeters(1, 90)).to.eql(0);
expect(iD.geoLonToMeters(1, 0)).to.be.within(110E3, 112E3);
expect(iD.geoLonToMeters(1, 15)).to.be.within(107E3, 108E3);
expect(iD.geoLonToMeters(1, 30)).to.be.within(96E3, 97E3);
expect(iD.geoLonToMeters(1, 45)).to.be.within(78E3, 79E3);
expect(iD.geoLonToMeters(1, 60)).to.be.within(55E3, 56E3);
expect(iD.geoLonToMeters(1, 75)).to.be.within(28E3, 29E3);
expect(iD.geoLonToMeters(1, 90)).to.eql(0);
});
it('distance of -1 degree longitude varies with latitude', function() {
expect(iD.geo.lonToMeters(-1, 0)).to.be.within(-112E3, -110E3);
expect(iD.geo.lonToMeters(-1, -15)).to.be.within(-108E3, -107E3);
expect(iD.geo.lonToMeters(-1, -30)).to.be.within(-97E3, -96E3);
expect(iD.geo.lonToMeters(-1, -45)).to.be.within(-79E3, -78E3);
expect(iD.geo.lonToMeters(-1, -60)).to.be.within(-56E3, -55E3);
expect(iD.geo.lonToMeters(-1, -75)).to.be.within(-29E3, -28E3);
expect(iD.geo.lonToMeters(-1, -90)).to.eql(0);
expect(iD.geoLonToMeters(-1, 0)).to.be.within(-112E3, -110E3);
expect(iD.geoLonToMeters(-1, -15)).to.be.within(-108E3, -107E3);
expect(iD.geoLonToMeters(-1, -30)).to.be.within(-97E3, -96E3);
expect(iD.geoLonToMeters(-1, -45)).to.be.within(-79E3, -78E3);
expect(iD.geoLonToMeters(-1, -60)).to.be.within(-56E3, -55E3);
expect(iD.geoLonToMeters(-1, -75)).to.be.within(-29E3, -28E3);
expect(iD.geoLonToMeters(-1, -90)).to.eql(0);
});
});
describe('.metersToLat', function() {
describe('geoMetersToLat', function() {
it('0 meters is 0 degrees latitude', function() {
expect(iD.geo.metersToLat(0)).to.eql(0);
expect(iD.geoMetersToLat(0)).to.eql(0);
});
it('111 km is approx 1 degree latitude', function() {
expect(iD.geo.metersToLat(111E3)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLat(111E3)).to.be.within(0.995, 1.005);
});
it('-111 km is approx -1 degree latitude', function() {
expect(iD.geo.metersToLat(-111E3)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLat(-111E3)).to.be.within(-1.005, -0.995);
});
});
describe('.metersToLon', function() {
describe('geoMetersToLon', function() {
it('0 meters is 0 degrees longitude', function() {
expect(iD.geo.metersToLon(0, 0)).to.eql(0);
expect(iD.geoMetersToLon(0, 0)).to.eql(0);
});
it('distance of 1 degree longitude varies with latitude', function() {
expect(iD.geo.metersToLon(111320, 0)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(107551, 15)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(96486, 30)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(78847, 45)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(55800, 60)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(28902, 75)).to.be.within(0.995, 1.005);
expect(iD.geo.metersToLon(1, 90)).to.eql(0);
expect(iD.geoMetersToLon(111320, 0)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(107551, 15)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(96486, 30)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(78847, 45)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(55800, 60)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(28902, 75)).to.be.within(0.995, 1.005);
expect(iD.geoMetersToLon(1, 90)).to.eql(0);
});
it('distance of -1 degree longitude varies with latitude', function() {
expect(iD.geo.metersToLon(-111320, 0)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-107551, 15)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-96486, 30)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-78847, 45)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-55800, 60)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-28902, 75)).to.be.within(-1.005, -0.995);
expect(iD.geo.metersToLon(-1, 90)).to.eql(0);
expect(iD.geoMetersToLon(-111320, 0)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-107551, 15)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-96486, 30)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-78847, 45)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-55800, 60)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-28902, 75)).to.be.within(-1.005, -0.995);
expect(iD.geoMetersToLon(-1, 90)).to.eql(0);
});
});
describe('.offsetToMeters', function() {
describe('geoOffsetToMeters', function() {
it('[0, 0] pixel offset is [0, -0] meter offset', function() {
var meters = iD.geo.offsetToMeters([0, 0]);
var meters = iD.geoOffsetToMeters([0, 0]);
expect(meters[0]).to.eql(0);
expect(meters[1]).to.eql(-0);
});
it('[0.00064, -0.00064] pixel offset is roughly [100, 100] meter offset', function() {
var meters = iD.geo.offsetToMeters([0.00064, -0.00064]);
var meters = iD.geoOffsetToMeters([0.00064, -0.00064]);
expect(meters[0]).to.be.within(99.5, 100.5);
expect(meters[1]).to.be.within(99.5, 100.5);
});
});
describe('.metersToOffset', function() {
describe('geoMetersToOffset', function() {
it('[0, 0] meter offset is [0, -0] pixel offset', function() {
var offset = iD.geo.metersToOffset([0, 0]);
var offset = iD.geoMetersToOffset([0, 0]);
expect(offset[0]).to.eql(0);
expect(offset[1]).to.eql(-0);
});
it('[100, 100] meter offset is roughly [0.00064, -0.00064] pixel offset', function() {
var offset = iD.geo.metersToOffset([100, 100]);
var offset = iD.geoMetersToOffset([100, 100]);
expect(offset[0]).to.be.within(0.000635, 0.000645);
expect(offset[1]).to.be.within(-0.000645, -0.000635);
});
});
describe('.sphericalDistance', function() {
describe('geoSphericalDistance', function() {
it('distance between two same points is zero', function() {
var a = [0, 0],
b = [0, 0];
expect(iD.geo.sphericalDistance(a, b)).to.eql(0);
expect(iD.geoSphericalDistance(a, b)).to.eql(0);
});
it('a straight 1 degree line at the equator is aproximately 111 km', function() {
var a = [0, 0],
b = [1, 0];
expect(iD.geo.sphericalDistance(a, b)).to.be.within(110E3, 112E3);
expect(iD.geoSphericalDistance(a, b)).to.be.within(110E3, 112E3);
});
it('a pythagorean triangle is (nearly) right', function() {
var a = [0, 0],
b = [4, 3];
expect(iD.geo.sphericalDistance(a, b)).to.be.within(555E3, 556E3);
expect(iD.geoSphericalDistance(a, b)).to.be.within(555E3, 556E3);
});
it('east-west distances at high latitude are shorter', function() {
var a = [0, 60],
b = [1, 60];
expect(iD.geo.sphericalDistance(a, b)).to.be.within(55E3, 56E3);
expect(iD.geoSphericalDistance(a, b)).to.be.within(55E3, 56E3);
});
it('north-south distances at high latitude are not shorter', function() {
var a = [0, 60],
b = [0, 61];
expect(iD.geo.sphericalDistance(a, b)).to.be.within(110E3, 112E3);
expect(iD.geoSphericalDistance(a, b)).to.be.within(110E3, 112E3);
});
});
describe('.chooseEdge', function() {
describe('geoChooseEdge', function() {
var projection = function (l) { return l; };
projection.invert = projection;
it('returns undefined properties for a degenerate way (no nodes)', function() {
expect(iD.geo.chooseEdge([], [0, 0], projection)).to.eql({
expect(iD.geoChooseEdge([], [0, 0], projection)).to.eql({
index: undefined,
distance: Infinity,
loc: undefined
@@ -198,7 +198,7 @@ describe('iD.geo', function() {
});
it('returns undefined properties for a degenerate way (single node)', function() {
expect(iD.geo.chooseEdge([iD.Node({loc: [0, 0]})], [0, 0], projection)).to.eql({
expect(iD.geoChooseEdge([iD.Node({loc: [0, 0]})], [0, 0], projection)).to.eql({
index: undefined,
distance: Infinity,
loc: undefined
@@ -219,7 +219,7 @@ describe('iD.geo', function() {
iD.Node({loc: b})
];
var choice = iD.geo.chooseEdge(nodes, c, projection);
var choice = iD.geoChooseEdge(nodes, c, projection);
expect(choice.index).to.eql(1);
expect(choice.distance).to.eql(1);
expect(choice.loc).to.eql([2, 0]);
@@ -234,7 +234,7 @@ describe('iD.geo', function() {
iD.Node({loc: b})
];
var choice = iD.geo.chooseEdge(nodes, c, projection);
var choice = iD.geoChooseEdge(nodes, c, projection);
expect(choice.index).to.eql(1);
expect(choice.distance).to.eql(5);
expect(choice.loc).to.eql([0, 0]);
@@ -249,46 +249,46 @@ describe('iD.geo', function() {
iD.Node({loc: b})
];
var choice = iD.geo.chooseEdge(nodes, c, projection);
var choice = iD.geoChooseEdge(nodes, c, projection);
expect(choice.index).to.eql(1);
expect(choice.distance).to.eql(5);
expect(choice.loc).to.eql([5, 0]);
});
});
describe('.lineIntersection', function() {
describe('geoLineIntersection', function() {
it('returns null if lines are colinear with overlap', function() {
var a = [[0, 0], [10, 0]],
b = [[-5, 0], [5, 0]];
expect(iD.geo.lineIntersection(a, b)).to.be.null;
expect(iD.geoLineIntersection(a, b)).to.be.null;
});
it('returns null if lines are colinear but disjoint', function() {
var a = [[5, 0], [10, 0]],
b = [[-10, 0], [-5, 0]];
expect(iD.geo.lineIntersection(a, b)).to.be.null;
expect(iD.geoLineIntersection(a, b)).to.be.null;
});
it('returns null if lines are parallel', function() {
var a = [[0, 0], [10, 0]],
b = [[0, 5], [10, 5]];
expect(iD.geo.lineIntersection(a, b)).to.be.null;
expect(iD.geoLineIntersection(a, b)).to.be.null;
});
it('returns the intersection point between 2 lines', function() {
var a = [[0, 0], [10, 0]],
b = [[5, 10], [5, -10]];
expect(iD.geo.lineIntersection(a, b)).to.eql([5, 0]);
expect(iD.geoLineIntersection(a, b)).to.eql([5, 0]);
});
it('returns null if lines are not parallel but not intersecting', function() {
var a = [[0, 0], [10, 0]],
b = [[-5, 10], [-5, -10]];
expect(iD.geo.lineIntersection(a, b)).to.be.null;
expect(iD.geoLineIntersection(a, b)).to.be.null;
});
});
describe('.pointInPolygon', function() {
describe('geoPointInPolygon', function() {
it('says a point in a polygon is on a polygon', function() {
var poly = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]];
var point = [0.5, 0.5];
expect(iD.geo.pointInPolygon(point, poly)).to.be.true;
expect(iD.geoPointInPolygon(point, poly)).to.be.true;
});
it('says a point outside of a polygon is outside', function() {
var poly = [
@@ -298,69 +298,69 @@ describe('iD.geo', function() {
[1, 0],
[0, 0]];
var point = [0.5, 1.5];
expect(iD.geo.pointInPolygon(point, poly)).to.be.false;
expect(iD.geoPointInPolygon(point, poly)).to.be.false;
});
});
describe('.polygonContainsPolygon', function() {
describe('geoPolygonContainsPolygon', function() {
it('says a polygon in a polygon is in', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]];
expect(iD.geo.polygonContainsPolygon(outer, inner)).to.be.true;
expect(iD.geoPolygonContainsPolygon(outer, inner)).to.be.true;
});
it('says a polygon outside of a polygon is out', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[1, 1], [1, 9], [2, 2], [2, 1], [1, 1]];
expect(iD.geo.polygonContainsPolygon(outer, inner)).to.be.false;
expect(iD.geoPolygonContainsPolygon(outer, inner)).to.be.false;
});
});
describe('.polygonIntersectsPolygon', function() {
describe('geoPolygonIntersectsPolygon', function() {
it('returns true when outer polygon fully contains inner', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]];
expect(iD.geo.polygonIntersectsPolygon(outer, inner)).to.be.true;
expect(iD.geoPolygonIntersectsPolygon(outer, inner)).to.be.true;
});
it('returns true when outer polygon partially contains inner (some vertices contained)', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[-1, -1], [1, 2], [2, 2], [2, 1], [1, 1]];
expect(iD.geo.polygonIntersectsPolygon(outer, inner)).to.be.true;
expect(iD.geoPolygonIntersectsPolygon(outer, inner)).to.be.true;
});
it('returns false when outer polygon partially contains inner (no vertices contained - lax test)', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[1, -1], [1, 4], [2, 4], [2, -1], [1, -1]];
expect(iD.geo.polygonIntersectsPolygon(outer, inner)).to.be.false;
expect(iD.geoPolygonIntersectsPolygon(outer, inner)).to.be.false;
});
it('returns true when outer polygon partially contains inner (no vertices contained - strict test)', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[1, -1], [1, 4], [2, 4], [2, -1], [1, -1]];
expect(iD.geo.polygonIntersectsPolygon(outer, inner, true)).to.be.true;
expect(iD.geoPolygonIntersectsPolygon(outer, inner, true)).to.be.true;
});
it('returns false when outer and inner are fully disjoint', function() {
var outer = [[0, 0], [0, 3], [3, 3], [3, 0], [0, 0]];
var inner = [[-1, -1], [-1, -2], [-2, -2], [-2, -1], [-1, -1]];
expect(iD.geo.polygonIntersectsPolygon(outer, inner)).to.be.false;
expect(iD.geoPolygonIntersectsPolygon(outer, inner)).to.be.false;
});
});
describe('.pathLength', function() {
describe('geoPathLength', function() {
it('calculates a simple path length', function() {
var path = [[0, 0], [0, 1], [3, 5]];
expect(iD.geo.pathLength(path)).to.eql(6);
expect(iD.geoPathLength(path)).to.eql(6);
});
it('does not fail on single-point path', function() {
var path = [[0, 0]];
expect(iD.geo.pathLength(path)).to.eql(0);
expect(iD.geoPathLength(path)).to.eql(0);
});
it('estimates zero-length edges', function() {
var path = [[0, 0], [0, 0]];
expect(iD.geo.pathLength(path)).to.eql(0);
expect(iD.geoPathLength(path)).to.eql(0);
});
});
});
+28 -28
View File
@@ -1,4 +1,4 @@
describe('iD.geo.Intersection', function() {
describe('iD.geoIntersection', function() {
describe('highways', function() {
it('excludes non-highways', function() {
var graph = iD.Graph([
@@ -8,7 +8,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*']}),
iD.Way({id: '-', nodes: ['*', 'w']})
]);
expect(iD.geo.Intersection(graph, '*').ways).to.eql([]);
expect(iD.geoIntersection(graph, '*').ways).to.eql([]);
});
it('excludes degenerate highways', function() {
@@ -18,7 +18,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*'], tags: {highway: 'residential'}})
]);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
expect(_.map(iD.geoIntersection(graph, '*').ways, 'id')).to.eql(['=']);
});
it('excludes coincident highways', function() {
@@ -28,7 +28,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['u', '*'], tags: {highway: 'residential'}})
]);
expect(iD.geo.Intersection(graph, '*').ways).to.eql([]);
expect(iD.geoIntersection(graph, '*').ways).to.eql([]);
});
it('includes line highways', function() {
@@ -39,7 +39,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*', 'w']})
]);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
expect(_.map(iD.geoIntersection(graph, '*').ways, 'id')).to.eql(['=']);
});
it('excludes area highways', function() {
@@ -49,7 +49,7 @@ describe('iD.geo.Intersection', function() {
iD.Node({id: 'w'}),
iD.Way({id: '=', nodes: ['u', '*', 'w'], tags: {highway: 'pedestrian', area: 'yes'}})
]);
expect(iD.geo.Intersection(graph, '*').ways).to.eql([]);
expect(iD.geoIntersection(graph, '*').ways).to.eql([]);
});
it('auto-splits highways at the intersection', function() {
@@ -59,7 +59,7 @@ describe('iD.geo.Intersection', function() {
iD.Node({id: 'w'}),
iD.Way({id: '=', nodes: ['u', '*', 'w'], tags: {highway: 'residential'}})
]);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
expect(_.map(iD.geoIntersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
});
});
@@ -73,7 +73,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -92,7 +92,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -116,7 +116,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*', 'x'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('w');
turns = iD.geoIntersection(graph, '*').turns('w');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
@@ -151,7 +151,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*', 'x'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
@@ -181,7 +181,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential', oneway: 'yes'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns).to.eql([{
from: {node: 'u', way: '='},
@@ -199,7 +199,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential', oneway: '-1'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns).to.eql([{
from: {node: 'u', way: '='},
@@ -217,7 +217,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential', oneway: 'yes'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]);
expect(iD.geo.Intersection(graph, '*').turns('u')).to.eql([]);
expect(iD.geoIntersection(graph, '*').turns('u')).to.eql([]);
});
it('omits turns from a reverse oneway forward', function() {
@@ -229,7 +229,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential', oneway: '-1'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]);
expect(iD.geo.Intersection(graph, '*').turns('u')).to.eql([]);
expect(iD.geoIntersection(graph, '*').turns('u')).to.eql([]);
});
it('permits turns onto a oneway forward', function() {
@@ -241,7 +241,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential', oneway: 'yes'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -260,7 +260,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*'], tags: {highway: 'residential', oneway: '-1'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -279,7 +279,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*'], tags: {highway: 'residential', oneway: 'yes'}})
]);
expect(iD.geo.Intersection(graph, '*').turns('u').length).to.eql(1);
expect(iD.geoIntersection(graph, '*').turns('u').length).to.eql(1);
});
it('omits turns onto a reverse oneway forward', function() {
@@ -291,7 +291,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential', oneway: '-1'}})
]);
expect(iD.geo.Intersection(graph, '*').turns('u').length).to.eql(1);
expect(iD.geoIntersection(graph, '*').turns('u').length).to.eql(1);
});
it('includes U-turns', function() {
@@ -303,7 +303,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['*', 'w'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[1]).to.eql({
@@ -328,7 +328,7 @@ describe('iD.geo.Intersection', function() {
{id: '*', role: 'via', type: 'node'}
]})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -357,7 +357,7 @@ describe('iD.geo.Intersection', function() {
{id: '*', role: 'via', type: 'node'}
]})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
@@ -398,7 +398,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
@@ -434,7 +434,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('a');
turns = iD.geoIntersection(graph, '*').turns('a');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
@@ -470,7 +470,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential', oneway: 'yes'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -501,7 +501,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential', oneway: '-1'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
turns = iD.geoIntersection(graph, '*').turns('u');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -532,7 +532,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential', oneway: 'yes'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('c');
turns = iD.geoIntersection(graph, '*').turns('c');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
@@ -562,7 +562,7 @@ describe('iD.geo.Intersection', function() {
iD.Way({id: '-', nodes: ['*', 'a', 'b', 'c', '*'], tags: {highway: 'residential', oneway: '-1'}}),
iD.Way({id: '=', nodes: ['*', 'u'], tags: {highway: 'residential'}})
]),
turns = iD.geo.Intersection(graph, '*').turns('a');
turns = iD.geoIntersection(graph, '*').turns('a');
expect(turns.length).to.eql(2);
expect(turns[0]).to.eql({
+13 -13
View File
@@ -1,4 +1,4 @@
describe('iD.geo.simpleMultipolygonOuterMember', function() {
describe('iD.geoSimpleMultipolygonOuterMember', function() {
it('returns the outer member of a simple multipolygon', function() {
var inner = iD.Way(),
outer = iD.Way(),
@@ -8,8 +8,8 @@ describe('iD.geo.simpleMultipolygonOuterMember', function() {
}),
graph = iD.Graph([inner, outer, relation]);
expect(iD.geo.simpleMultipolygonOuterMember(inner, graph)).to.equal(outer);
expect(iD.geo.simpleMultipolygonOuterMember(outer, graph)).to.equal(outer);
expect(iD.geoSimpleMultipolygonOuterMember(inner, graph)).to.equal(outer);
expect(iD.geoSimpleMultipolygonOuterMember(outer, graph)).to.equal(outer);
});
it('returns falsy for a complex multipolygon', function() {
@@ -23,9 +23,9 @@ describe('iD.geo.simpleMultipolygonOuterMember', function() {
}),
graph = iD.Graph([inner, outer1, outer2, relation]);
expect(iD.geo.simpleMultipolygonOuterMember(inner, graph)).not.to.be.ok;
expect(iD.geo.simpleMultipolygonOuterMember(outer1, graph)).not.to.be.ok;
expect(iD.geo.simpleMultipolygonOuterMember(outer2, graph)).not.to.be.ok;
expect(iD.geoSimpleMultipolygonOuterMember(inner, graph)).not.to.be.ok;
expect(iD.geoSimpleMultipolygonOuterMember(outer1, graph)).not.to.be.ok;
expect(iD.geoSimpleMultipolygonOuterMember(outer2, graph)).not.to.be.ok;
});
it('handles incomplete relations', function() {
@@ -36,17 +36,17 @@ describe('iD.geo.simpleMultipolygonOuterMember', function() {
}),
graph = iD.Graph([way, relation]);
expect(iD.geo.simpleMultipolygonOuterMember(way, graph)).to.be.undefined;
expect(iD.geoSimpleMultipolygonOuterMember(way, graph)).to.be.undefined;
});
});
describe('iD.geo.joinWays', function() {
describe('iD.geoJoinWays', function() {
it('returns an array of members with nodes properties', function() {
var node = iD.Node({loc: [0, 0]}),
way = iD.Way({nodes: [node.id]}),
member = {id: way.id, type: 'way'},
graph = iD.Graph([node, way]),
result = iD.geo.joinWays([member], graph);
result = iD.geoJoinWays([member], graph);
expect(result.length).to.equal(1);
expect(result[0].nodes.length).to.equal(1);
@@ -72,7 +72,7 @@ describe('iD.geo.joinWays', function() {
]})
]);
var result = iD.geo.joinWays(graph.entity('r').members, graph);
var result = iD.geoJoinWays(graph.entity('r').members, graph);
expect(_.map(result[0], 'id')).to.eql(['=', '-', '~']);
});
@@ -89,7 +89,7 @@ describe('iD.geo.joinWays', function() {
iD.Way({id: '=', nodes: ['c', 'b'], tags: {'oneway': 'yes', 'lanes:forward': 2}})
]);
var result = iD.geo.joinWays([graph.entity('-'), graph.entity('=')], graph);
var result = iD.geoJoinWays([graph.entity('-'), graph.entity('=')], graph);
expect(result[0][1].tags).to.eql({'oneway': '-1', 'lanes:backward': 2});
});
@@ -97,12 +97,12 @@ describe('iD.geo.joinWays', function() {
var node = iD.Node({loc: [0, 0]}),
member = {id: 'n', type: 'node'},
graph = iD.Graph([node]);
expect(iD.geo.joinWays([member], graph)).to.eql([]);
expect(iD.geoJoinWays([member], graph)).to.eql([]);
});
it('ignores incomplete members', function() {
var member = {id: 'w', type: 'way'},
graph = iD.Graph();
expect(iD.geo.joinWays([member], graph)).to.eql([]);
expect(iD.geoJoinWays([member], graph)).to.eql([]);
});
});
+3 -3
View File
@@ -1,11 +1,11 @@
describe('iD.modes.AddPoint', function() {
describe('iD.modeAddPoint', function() {
var context;
beforeEach(function() {
var container = d3.select(document.createElement('div'));
context = iD.Context(window)
.presets(iD.data.presets)
.presets(iD.dataPresets)
.imagery([])
.container(container);
@@ -16,7 +16,7 @@ describe('iD.modes.AddPoint', function() {
.attr('class', 'inspector-wrap');
context.map().centerZoom([-77.02271, 38.90085], 20);
context.enter(iD.modes.AddPoint(context));
context.enter(iD.modeAddPoint(context));
});
describe('clicking the map', function () {
+4 -4
View File
@@ -1,4 +1,4 @@
describe('iD.presets.Category', function() {
describe('iD.presetCategory', function() {
var category, residential;
beforeEach(function() {
@@ -10,7 +10,7 @@ describe('iD.presets.Category', function() {
'highway/residential'
]
};
residential = iD.presets.Preset('highway/residential', {
residential = iD.presetPreset('highway/residential', {
tags: {
highway: 'residential'
},
@@ -19,13 +19,13 @@ describe('iD.presets.Category', function() {
});
it('maps members names to preset instances', function() {
var c = iD.presets.Category('road', category, iD.presets.Collection([residential]));
var c = iD.presetCategory('road', category, iD.presetCollection([residential]));
expect(c.members.collection[0]).to.eql(residential);
});
describe('#matchGeometry', function() {
it('matches the type of an entity', function() {
var c = iD.presets.Category('road', category, iD.presets.Collection([residential]));
var c = iD.presetCategory('road', category, iD.presetCollection([residential]));
expect(c.matchGeometry('line')).to.eql(true);
expect(c.matchGeometry('point')).to.eql(false);
});
+15 -15
View File
@@ -1,63 +1,63 @@
describe('iD.presets.Collection', function() {
describe('iD.presetCollection', function() {
var p = {
point: iD.presets.Preset('point', {
point: iD.presetPreset('point', {
name: 'Point',
tags: {},
geometry: ['point']
}),
line: iD.presets.Preset('line', {
line: iD.presetPreset('line', {
name: 'Line',
tags: {},
geometry: ['line']
}),
area: iD.presets.Preset('area', {
area: iD.presetPreset('area', {
name: 'Area',
tags: {},
geometry: ['area']
}),
grill: iD.presets.Preset('__test/amenity/bbq', {
grill: iD.presetPreset('__test/amenity/bbq', {
name: 'Grill',
tags: { amenity: 'bbq' },
geometry: ['point'],
terms: []
}),
sandpit: iD.presets.Preset('__test/amenity/grit_bin', {
sandpit: iD.presetPreset('__test/amenity/grit_bin', {
name: 'Sandpit',
tags: { amenity: 'grit_bin' },
geometry: ['point'],
terms: []
}),
residential: iD.presets.Preset('__test/highway/residential', {
residential: iD.presetPreset('__test/highway/residential', {
name: 'Residential Area',
tags: { highway: 'residential' },
geometry: ['point', 'area'],
terms: []
}),
grass1: iD.presets.Preset('__test/landuse/grass1', {
grass1: iD.presetPreset('__test/landuse/grass1', {
name: 'Grass',
tags: { landuse: 'grass' },
geometry: ['point', 'area'],
terms: []
}),
grass2: iD.presets.Preset('__test/landuse/grass2', {
grass2: iD.presetPreset('__test/landuse/grass2', {
name: 'Ğṝȁß',
tags: { landuse: 'ğṝȁß' },
geometry: ['point', 'area'],
terms: []
}),
park: iD.presets.Preset('__test/leisure/park', {
park: iD.presetPreset('__test/leisure/park', {
name: 'Park',
tags: { leisure: 'park' },
geometry: ['point', 'area'],
terms: [ 'grass' ]
}),
soccer: iD.presets.Preset('__test/leisure/pitch/soccer', {
soccer: iD.presetPreset('__test/leisure/pitch/soccer', {
name: 'Soccer Field',
tags: { leisure: 'pitch', sport: 'soccer' },
geometry: ['point', 'area'],
terms: ['fußball']
}),
football: iD.presets.Preset('__test/leisure/pitch/american_football', {
football: iD.presetPreset('__test/leisure/pitch/american_football', {
name: 'Football Field',
tags: { leisure: 'pitch', sport: 'american_football' },
geometry: ['point', 'area'],
@@ -66,7 +66,7 @@ describe('iD.presets.Collection', function() {
};
var c = iD.presets.Collection([
var c = iD.presetCollection([
p.point, p.line, p.area, p.grill, p.sandpit, p.residential,
p.grass1, p.grass2, p.park, p.soccer, p.football
]);
@@ -120,13 +120,13 @@ describe('iD.presets.Collection', function() {
});
it('excludes presets with searchable: false', function() {
var excluded = iD.presets.Preset('__test/excluded', {
var excluded = iD.presetPreset('__test/excluded', {
name: 'excluded',
tags: { amenity: 'excluded' },
geometry: ['point'],
searchable: false
}),
collection = iD.presets.Collection([excluded, p.point]);
collection = iD.presetCollection([excluded, p.point]);
expect(collection.search('excluded', 'point').collection).not.to.include(excluded);
});
});
+29 -29
View File
@@ -1,47 +1,47 @@
/* globals context: true */
describe('iD.presets.Preset', function() {
describe('iD.presetPreset', function() {
it('has optional fields', function() {
var preset = iD.presets.Preset('test', {});
var preset = iD.presetPreset('test', {});
expect(preset.fields).to.eql([]);
});
describe('#matchGeometry', function() {
it('returns false if it doesn\'t match', function() {
var preset = iD.presets.Preset('test', {geometry: ['line']});
var preset = iD.presetPreset('test', {geometry: ['line']});
expect(preset.matchGeometry('point')).to.equal(false);
});
it('returns true if it does match', function() {
var preset = iD.presets.Preset('test', {geometry: ['point', 'line']});
var preset = iD.presetPreset('test', {geometry: ['point', 'line']});
expect(preset.matchGeometry('point')).to.equal(true);
});
});
describe('#matchScore', function() {
it('returns -1 if preset does not match tags', function() {
var preset = iD.presets.Preset('test', {tags: {foo: 'bar'}}),
var preset = iD.presetPreset('test', {tags: {foo: 'bar'}}),
entity = iD.Way({tags: {highway: 'motorway'}});
expect(preset.matchScore(entity)).to.equal(-1);
});
it('returns the value of the matchScore property when matched', function() {
var preset = iD.presets.Preset('test', {tags: {highway: 'motorway'}, matchScore: 0.2}),
var preset = iD.presetPreset('test', {tags: {highway: 'motorway'}, matchScore: 0.2}),
entity = iD.Way({tags: {highway: 'motorway'}});
expect(preset.matchScore(entity)).to.equal(0.2);
});
it('defaults to the number of matched tags', function() {
var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}}),
var preset = iD.presetPreset('test', {tags: {highway: 'residential'}}),
entity = iD.Way({tags: {highway: 'residential'}});
expect(preset.matchScore(entity)).to.equal(1);
preset = iD.presets.Preset('test', {tags: {highway: 'service', service: 'alley'}});
preset = iD.presetPreset('test', {tags: {highway: 'service', service: 'alley'}});
entity = iD.Way({tags: {highway: 'service', service: 'alley'}});
expect(preset.matchScore(entity)).to.equal(2);
});
it('counts * as a match for any value with score 0.5', function() {
var preset = iD.presets.Preset('test', {tags: {building: '*'}}),
var preset = iD.presetPreset('test', {tags: {building: '*'}}),
entity = iD.Way({tags: {building: 'yep'}});
expect(preset.matchScore(entity)).to.equal(0.5);
});
@@ -49,56 +49,56 @@ describe('iD.presets.Preset', function() {
describe('isFallback', function() {
it('returns true if preset has no tags', function() {
var preset = iD.presets.Preset('point', {tags: {}});
var preset = iD.presetPreset('point', {tags: {}});
expect(preset.isFallback()).to.equal(true);
});
it('returns true if preset has a single \'area\' tag', function() {
var preset = iD.presets.Preset('area', {tags: {area: 'yes'}});
var preset = iD.presetPreset('area', {tags: {area: 'yes'}});
expect(preset.isFallback()).to.equal(true);
});
it('returns false if preset has a single non-\'area\' tag', function() {
var preset = iD.presets.Preset('building', {tags: {building: 'yes'}});
var preset = iD.presetPreset('building', {tags: {building: 'yes'}});
expect(preset.isFallback()).to.equal(false);
});
it('returns false if preset has multiple tags', function() {
var preset = iD.presets.Preset('building', {tags: {area: 'yes', building: 'yes'}});
var preset = iD.presetPreset('building', {tags: {area: 'yes', building: 'yes'}});
expect(preset.isFallback()).to.equal(false);
});
});
describe('#applyTags', function() {
it('adds match tags', function() {
var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}});
var preset = iD.presetPreset('test', {tags: {highway: 'residential'}});
expect(preset.applyTags({}, 'line')).to.eql({highway: 'residential'});
});
it('adds wildcard tags with value \'yes\'', function() {
var preset = iD.presets.Preset('test', {tags: {building: '*'}});
var preset = iD.presetPreset('test', {tags: {building: '*'}});
expect(preset.applyTags({}, 'area')).to.eql({building: 'yes'});
});
it('prefers to add tags of addTags property', function() {
var preset = iD.presets.Preset('test', {tags: {building: '*'}, addTags: {building: 'ok'}});
var preset = iD.presetPreset('test', {tags: {building: '*'}, addTags: {building: 'ok'}});
expect(preset.applyTags({}, 'area')).to.eql({building: 'ok'});
});
it('adds default tags of fields with matching geometry', function() {
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
var field = iD.presetField('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presetPreset('test', {fields: ['field']}, {field: field});
expect(preset.applyTags({}, 'area')).to.eql({area: 'yes', building: 'yes'});
});
it('adds no default tags of fields with non-matching geometry', function() {
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
var field = iD.presetField('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presetPreset('test', {fields: ['field']}, {field: field});
expect(preset.applyTags({}, 'point')).to.eql({});
});
context('for a preset with no tag in areaKeys', function() {
var preset = iD.presets.Preset('test', {geometry: ['line', 'area'], tags: {name: 'testname', highway: 'pedestrian'}});
var preset = iD.presetPreset('test', {geometry: ['line', 'area'], tags: {name: 'testname', highway: 'pedestrian'}});
it('doesn\'t add area=yes to non-areas', function() {
expect(preset.applyTags({}, 'line')).to.eql({name: 'testname', highway: 'pedestrian'});
@@ -110,7 +110,7 @@ describe('iD.presets.Preset', function() {
});
context('for a preset with a tag in areaKeys', function() {
var preset = iD.presets.Preset('test', {geometry: ['area'], tags: {name: 'testname', natural: 'water'}});
var preset = iD.presetPreset('test', {geometry: ['area'], tags: {name: 'testname', natural: 'water'}});
it('doesn\'t add area=yes', function() {
expect(preset.applyTags({}, 'area')).to.eql({name: 'testname', natural: 'water'});
});
@@ -119,29 +119,29 @@ describe('iD.presets.Preset', function() {
describe('#removeTags', function() {
it('removes tags that match preset tags', function() {
var preset = iD.presets.Preset('test', {tags: {highway: 'residential'}});
var preset = iD.presetPreset('test', {tags: {highway: 'residential'}});
expect(preset.removeTags({highway: 'residential'}, 'area')).to.eql({});
});
it('removes tags that match field default tags', function() {
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
var field = iD.presetField('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presetPreset('test', {fields: ['field']}, {field: field});
expect(preset.removeTags({building: 'yes'}, 'area')).to.eql({});
});
it('removes area=yes', function() {
var preset = iD.presets.Preset('test', {tags: {highway: 'pedestrian'}});
var preset = iD.presetPreset('test', {tags: {highway: 'pedestrian'}});
expect(preset.removeTags({highway: 'pedestrian', area: 'yes'}, 'area')).to.eql({});
});
it('preserves tags that do not match field default tags', function() {
var field = iD.presets.Field('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presets.Preset('test', {fields: ['field']}, {field: field});
var field = iD.presetField('field', {key: 'building', geometry: 'area', default: 'yes'}),
preset = iD.presetPreset('test', {fields: ['field']}, {field: field});
expect(preset.removeTags({building: 'yep'}, 'area')).to.eql({ building: 'yep'});
});
it('preserves tags that are not listed in removeTags', function() {
var preset = iD.presets.Preset('test', {tags: {a: 'b'}, removeTags: {}});
var preset = iD.presetPreset('test', {tags: {a: 'b'}, removeTags: {}});
expect(preset.removeTags({a: 'b'}, 'area')).to.eql({a: 'b'});
});
});
+4 -4
View File
@@ -1,4 +1,4 @@
describe('iD.presets.presets', function() {
describe('iD.presetInit', function() {
var p = {
point: {
tags: {},
@@ -22,7 +22,7 @@ describe('iD.presets.presets', function() {
}
};
var c = iD.presets.presets().load({presets: p});
var c = iD.presetInit().load({presets: p});
describe('#match', function() {
it('returns a collection containing presets matching a geometry and tags', function() {
@@ -59,7 +59,7 @@ describe('iD.presets.presets', function() {
});
describe('#areaKeys', function() {
var presets = iD.presets.presets().load({
var presets = iD.presetInit().load({
presets: {
'amenity/fuel/shell': {
tags: { 'amenity': 'fuel' },
@@ -128,7 +128,7 @@ describe('iD.presets.presets', function() {
var presets;
before(function() {
presets = iD.presets.presets().load(iD.data.presets);
presets = iD.presetInit().load(iD.dataPresets);
});
it('prefers building to multipolygon', function() {
+1 -1
View File
@@ -2,7 +2,7 @@ describe('iD.Map', function() {
var context, map;
beforeEach(function() {
context = iD.Context(window).imagery(iD.data.imagery);
context = iD.Context(window).imagery(iD.dataImagery);
context.container(d3.select(document.createElement('div')));
map = context.map();
d3.select(document.createElement('div'))
+17 -17
View File
@@ -1,4 +1,4 @@
describe('iD.services.mapillary', function() {
describe('iD.serviceMapillary', function() {
var dimensions = [64, 64],
ua = navigator.userAgent,
isPhantom = (navigator.userAgent.match(/PhantomJS/) !== null),
@@ -12,7 +12,7 @@ describe('iD.services.mapillary', function() {
context.projection.translate([-116508, 0]); // 10,0
server = sinon.fakeServer.create();
mapillary = iD.services.mapillary.init();
mapillary = iD.serviceMapillary.init();
mapillary.reset();
/* eslint-disable no-native-reassign */
@@ -41,12 +41,12 @@ describe('iD.services.mapillary', function() {
describe('Mapillary service', function() {
it('Initializes cache one time', function() {
var cache = iD.services.mapillary.getMapillary().cache;
var cache = iD.serviceMapillary.getMapillary().cache;
expect(cache).to.have.property('images');
expect(cache).to.have.property('signs');
iD.services.mapillary.init();
var cache2 = iD.services.mapillary.getMapillary().cache;
iD.serviceMapillary.init();
var cache2 = iD.serviceMapillary.getMapillary().cache;
expect(cache).to.equal(cache2);
});
});
@@ -145,7 +145,7 @@ describe('iD.services.mapillary', function() {
});
server.respond();
var sign_defs = iD.services.mapillary.getMapillary().sign_defs;
var sign_defs = iD.serviceMapillary.getMapillary().sign_defs;
expect(sign_defs).to.have.property('au')
.that.is.an('object')
@@ -274,7 +274,7 @@ describe('iD.services.mapillary', function() {
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], ca: 90 } }
];
iD.services.mapillary.getMapillary().cache.images.rtree.load(features);
iD.serviceMapillary.getMapillary().cache.images.rtree.load(features);
var res = mapillary.images(context.projection, dimensions);
expect(res).to.deep.eql([
@@ -292,7 +292,7 @@ describe('iD.services.mapillary', function() {
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0], ca: 90 } }
];
iD.services.mapillary.getMapillary().cache.images.rtree.load(features);
iD.serviceMapillary.getMapillary().cache.images.rtree.load(features);
var res = mapillary.images(context.projection, dimensions);
expect(res).to.have.length.of.at.most(3);
});
@@ -313,7 +313,7 @@ describe('iD.services.mapillary', function() {
{ minX: 10, minY: 1, maxX: 10, maxY: 1, data: { key: '2', loc: [10,1], signs: signs } }
];
iD.services.mapillary.getMapillary().cache.signs.rtree.load(features);
iD.serviceMapillary.getMapillary().cache.signs.rtree.load(features);
var res = mapillary.signs(context.projection, dimensions);
expect(res).to.deep.eql([
@@ -338,7 +338,7 @@ describe('iD.services.mapillary', function() {
{ minX: 10, minY: 0, maxX: 10, maxY: 0, data: { key: '4', loc: [10,0], signs: signs } }
];
iD.services.mapillary.getMapillary().cache.signs.rtree.load(features);
iD.serviceMapillary.getMapillary().cache.signs.rtree.load(features);
var res = mapillary.signs(context.projection, dimensions);
expect(res).to.have.length.of.at.most(3);
});
@@ -358,7 +358,7 @@ describe('iD.services.mapillary', function() {
describe('#signHTML', function() {
it('returns sign HTML', function() {
iD.services.mapillary.getMapillary().sign_defs = {
iD.serviceMapillary.getMapillary().sign_defs = {
us: {'regulatory--maximum-speed-limit-65--us': '<span class="t">65</span>'}
};
@@ -381,25 +381,25 @@ describe('iD.services.mapillary', function() {
describe('#setSelectedImage', function() {
it('sets selected image', function() {
mapillary.setSelectedImage('foo');
expect(iD.services.mapillary.getMapillary().image).to.eql('foo');
expect(iD.serviceMapillary.getMapillary().image).to.eql('foo');
});
});
describe('#getSelectedImage', function() {
it('gets selected image', function() {
iD.services.mapillary.getMapillary().image = 'bar';
iD.serviceMapillary.getMapillary().image = 'bar';
expect(mapillary.getSelectedImage()).to.eql('bar');
});
});
describe('#reset', function() {
it('resets cache and image', function() {
iD.services.mapillary.getMapillary().cache.foo = 'bar';
iD.services.mapillary.getMapillary().image = 'bar';
iD.serviceMapillary.getMapillary().cache.foo = 'bar';
iD.serviceMapillary.getMapillary().image = 'bar';
mapillary.reset();
expect(iD.services.mapillary.getMapillary().cache).to.not.have.property('foo');
expect(iD.services.mapillary.getMapillary().image).to.be.null;
expect(iD.serviceMapillary.getMapillary().cache).to.not.have.property('foo');
expect(iD.serviceMapillary.getMapillary().image).to.be.null;
});
});
+5 -5
View File
@@ -1,11 +1,11 @@
describe('iD.services.nominatim', function() {
describe('iD.serviceNominatim', function() {
var server, nominatim;
beforeEach(function() {
server = sinon.fakeServer.create();
iD.services.nominatim.init();
nominatim = iD.services.nominatim;
iD.services.nominatim.reset();
iD.serviceNominatim.init();
nominatim = iD.serviceNominatim;
iD.serviceNominatim.reset();
});
afterEach(function() {
@@ -13,7 +13,7 @@ describe('iD.services.nominatim', function() {
});
function query(url) {
return iD.util.stringQs(url.substring(url.indexOf('?') + 1));
return iD.utilStringQs(url.substring(url.indexOf('?') + 1));
}
describe.skip('#countryCode', function() {
+3 -3
View File
@@ -1,9 +1,9 @@
describe('iD.services.taginfo', function() {
describe('iD.serviceTaginfo', function() {
var server, taginfo;
beforeEach(function() {
server = sinon.fakeServer.create();
taginfo = iD.services.taginfo.init();
taginfo = iD.serviceTaginfo.init();
taginfo.reset();
});
@@ -12,7 +12,7 @@ describe('iD.services.taginfo', function() {
});
function query(url) {
return iD.util.stringQs(url.substring(url.indexOf('?') + 1));
return iD.utilStringQs(url.substring(url.indexOf('?') + 1));
}
describe('#keys', function() {
+15 -15
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Areas', function () {
describe('iD.svgAreas', function () {
var context, surface,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -30,7 +30,7 @@ describe('iD.svg.Areas', function () {
iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']})
]);
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('w')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('w')], none);
expect(surface.select('path.way')).to.be.classed('way');
expect(surface.select('path.area')).to.be.classed('area');
@@ -45,7 +45,7 @@ describe('iD.svg.Areas', function () {
iD.Way({id: 'w', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'a']})
]);
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('w')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('w')], none);
expect(surface.select('.area')).to.be.classed('tag-building');
expect(surface.select('.area')).to.be.classed('tag-building-yes');
@@ -61,10 +61,10 @@ describe('iD.svg.Areas', function () {
iD.Way({id: 'x', tags: {area: 'yes'}, nodes: ['a', 'b', 'd', 'a']})
]);
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('x')], all);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('x')], all);
graph = graph.remove(graph.entity('x')).remove(graph.entity('d'));
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('w')], all);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('w')], all);
expect(surface.select('.area').size()).to.equal(1);
});
@@ -83,30 +83,30 @@ describe('iD.svg.Areas', function () {
]);
it('stacks smaller areas above larger ones in a single render', function () {
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('s'), graph.entity('l')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('s'), graph.entity('l')], none);
expect(surface.select('.area:nth-child(1)')).to.be.classed('tag-landuse-park');
expect(surface.select('.area:nth-child(2)')).to.be.classed('tag-building-yes');
});
it('stacks smaller areas above larger ones in a single render (reverse)', function () {
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('l'), graph.entity('s')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('l'), graph.entity('s')], none);
expect(surface.select('.area:nth-child(1)')).to.be.classed('tag-landuse-park');
expect(surface.select('.area:nth-child(2)')).to.be.classed('tag-building-yes');
});
it('stacks smaller areas above larger ones in separate renders', function () {
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('s')], none);
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('l')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('s')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('l')], none);
expect(surface.select('.area:nth-child(1)')).to.be.classed('tag-landuse-park');
expect(surface.select('.area:nth-child(2)')).to.be.classed('tag-building-yes');
});
it('stacks smaller areas above larger ones in separate renders (reverse)', function () {
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('l')], none);
surface.call(iD.svg.Areas(projection, context), graph, [graph.entity('s')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('l')], none);
surface.call(iD.svgAreas(projection, context), graph, [graph.entity('s')], none);
expect(surface.select('.area:nth-child(1)')).to.be.classed('tag-landuse-park');
expect(surface.select('.area:nth-child(2)')).to.be.classed('tag-building-yes');
@@ -122,7 +122,7 @@ describe('iD.svg.Areas', function () {
graph = iD.Graph([a, b, c, w, r]),
areas = [w, r];
surface.call(iD.svg.Areas(projection, context), graph, areas, none);
surface.call(iD.svgAreas(projection, context), graph, areas, none);
expect(surface.select('.fill')).to.be.classed('relation');
});
@@ -136,7 +136,7 @@ describe('iD.svg.Areas', function () {
graph = iD.Graph([a, b, c, w, r]),
areas = [w, r];
surface.call(iD.svg.Areas(projection, context), graph, areas, none);
surface.call(iD.svgAreas(projection, context), graph, areas, none);
expect(surface.selectAll('.stroke').size()).to.equal(0);
});
@@ -149,7 +149,7 @@ describe('iD.svg.Areas', function () {
r = iD.Relation({members: [{id: w.id, type: 'way'}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([a, b, c, w, r]);
surface.call(iD.svg.Areas(projection, context), graph, [w, r], none);
surface.call(iD.svgAreas(projection, context), graph, [w, r], none);
expect(surface.selectAll('.way.fill').size()).to.equal(0);
expect(surface.selectAll('.relation.fill').size()).to.equal(1);
@@ -164,7 +164,7 @@ describe('iD.svg.Areas', function () {
r = iD.Relation({members: [{id: w.id, type: 'way'}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([a, b, c, w, r]);
surface.call(iD.svg.Areas(projection, context), graph, [w, r], none);
surface.call(iD.svgAreas(projection, context), graph, [w, r], none);
expect(surface.selectAll('.stroke').size()).to.equal(0);
});
+3 -3
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Icon', function () {
describe('iD.svgIcon', function () {
var selection;
beforeEach(function () {
@@ -6,13 +6,13 @@ describe('iD.svg.Icon', function () {
});
it('creates a generic SVG icon', function () {
selection.call(iD.svg.Icon('#icon-bug'));
selection.call(iD.svgIcon('#icon-bug'));
expect(selection.select('svg')).to.be.classed('icon');
expect(selection.select('use').attr('xlink:href')).to.eql('#icon-bug');
});
it('classes the \'svg\' and \'use\' elements', function () {
selection.call(iD.svg.Icon('#icon-bug', 'svg-class', 'use-class'));
selection.call(iD.svgIcon('#icon-bug', 'svg-class', 'use-class'));
expect(selection.select('svg')).to.be.classed('icon svg-class');
expect(selection.select('use')).to.be.classed('use-class');
});
+4 -4
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Layers', function () {
describe('iD.svgLayers', function () {
var context, container,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -12,19 +12,19 @@ describe('iD.svg.Layers', function () {
it('creates a surface', function () {
container.call(iD.svg.Layers(projection, context));
container.call(iD.svgLayers(projection, context));
expect(container.selectAll('svg')).to.be.classed('surface');
});
it('creates surface defs', function () {
container.call(iD.svg.Layers(projection, context));
container.call(iD.svgLayers(projection, context));
var nodes = container.selectAll('svg defs').nodes();
expect(nodes.length).to.eql(1);
expect(d3.select(nodes[0])).to.be.classed('surface-defs');
});
it('creates default data layers', function () {
container.call(iD.svg.Layers(projection, context));
container.call(iD.svgLayers(projection, context));
var nodes = container.selectAll('svg .data-layer').nodes();
expect(nodes.length).to.eql(5);
expect(d3.select(nodes[0])).to.be.classed('data-layer-osm');
+12 -12
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Lines', function () {
describe('iD.svgLines', function () {
var context, surface,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -22,7 +22,7 @@ describe('iD.svg.Lines', function () {
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]);
surface.call(iD.svg.Lines(projection), graph, [line], all);
surface.call(iD.svgLines(projection), graph, [line], all);
expect(surface.select('path.way')).to.be.classed('way');
expect(surface.select('path.line')).to.be.classed('line');
@@ -34,7 +34,7 @@ describe('iD.svg.Lines', function () {
line = iD.Way({nodes: [a.id, b.id], tags: {highway: 'residential'}}),
graph = iD.Graph([a, b, line]);
surface.call(iD.svg.Lines(projection), graph, [line], all);
surface.call(iD.svgLines(projection), graph, [line], all);
expect(surface.select('.line')).to.be.classed('tag-highway');
expect(surface.select('.line')).to.be.classed('tag-highway-residential');
@@ -47,7 +47,7 @@ describe('iD.svg.Lines', function () {
relation = iD.Relation({members: [{id: line.id}], tags: {type: 'multipolygon', natural: 'wood'}}),
graph = iD.Graph([a, b, line, relation]);
surface.call(iD.svg.Lines(projection), graph, [line], all);
surface.call(iD.svgLines(projection), graph, [line], all);
expect(surface.select('.stroke')).to.be.classed('tag-natural-wood');
});
@@ -60,7 +60,7 @@ describe('iD.svg.Lines', function () {
r = iD.Relation({members: [{id: w.id}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([a, b, c, w, r]);
surface.call(iD.svg.Lines(projection), graph, [w], all);
surface.call(iD.svgLines(projection), graph, [w], all);
expect(surface.select('.stroke')).to.be.classed('tag-natural-wood');
});
@@ -74,7 +74,7 @@ describe('iD.svg.Lines', function () {
r = iD.Relation({members: [{id: o.id, role: 'outer'}, {id: i.id, role: 'inner'}], tags: {type: 'multipolygon'}}),
graph = iD.Graph([a, b, c, o, i, r]);
surface.call(iD.svg.Lines(projection), graph, [i], all);
surface.call(iD.svgLines(projection), graph, [i], all);
expect(surface.select('.stroke')).to.be.classed('tag-natural-wood');
});
@@ -90,7 +90,7 @@ describe('iD.svg.Lines', function () {
]);
it('stacks higher lines above lower ones in a single render', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('lo'), graph.entity('hi')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('lo'), graph.entity('hi')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
@@ -98,7 +98,7 @@ describe('iD.svg.Lines', function () {
});
it('stacks higher lines above lower ones in a single render (reverse)', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('hi'), graph.entity('lo')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('hi'), graph.entity('lo')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
@@ -106,8 +106,8 @@ describe('iD.svg.Lines', function () {
});
it('stacks higher lines above lower ones in separate renders', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('lo')], none);
surface.call(iD.svg.Lines(projection), graph, [graph.entity('hi')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('lo')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('hi')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
@@ -115,8 +115,8 @@ describe('iD.svg.Lines', function () {
});
it('stacks higher lines above lower in separate renders (reverse)', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('hi')], none);
surface.call(iD.svg.Lines(projection), graph, [graph.entity('lo')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('hi')], none);
surface.call(iD.svgLines(projection), graph, [graph.entity('lo')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
+11 -11
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Midpoints', function () {
describe('iD.svgMidpoints', function () {
var context, surface,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -20,11 +20,11 @@ describe('iD.svg.Midpoints', function () {
b = iD.Node({loc: [50, 0]}),
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]),
extent = iD.geo.Extent([0, 0], [100, 100]);
extent = iD.geoExtent([0, 0], [100, 100]);
context.selectedIDs = function() { return [line.id]; };
context.entity = function(id) { return graph.entity(id); };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
surface.call(iD.svgMidpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint').datum().loc).to.eql([25, 0]);
});
@@ -34,10 +34,10 @@ describe('iD.svg.Midpoints', function () {
b = iD.Node({loc: [39, 0]}),
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]),
extent = iD.geo.Extent([0, 0], [100, 100]);
extent = iD.geoExtent([0, 0], [100, 100]);
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
surface.call(iD.svgMidpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
@@ -47,10 +47,10 @@ describe('iD.svg.Midpoints', function () {
b = iD.Node({loc: [-50, 0]}),
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]),
extent = iD.geo.Extent([0, 0], [100, 100]);
extent = iD.geoExtent([0, 0], [100, 100]);
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
surface.call(iD.svgMidpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
@@ -60,11 +60,11 @@ describe('iD.svg.Midpoints', function () {
b = iD.Node({loc: [500, 0]}),
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]),
extent = iD.geo.Extent([0, 0], [100, 100]);
extent = iD.geoExtent([0, 0], [100, 100]);
context.selectedIDs = function() { return [line.id]; };
context.entity = function(id) { return graph.entity(id); };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
surface.call(iD.svgMidpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint').datum().loc).to.eql([100, 0]);
});
@@ -74,10 +74,10 @@ describe('iD.svg.Midpoints', function () {
b = iD.Node({loc: [500, 0]}),
line = iD.Way({nodes: [a.id, b.id]}),
graph = iD.Graph([a, b, line]),
extent = iD.geo.Extent([0, 0], [100, 100]);
extent = iD.geoExtent([0, 0], [100, 100]);
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
surface.call(iD.svgMidpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Osm', function () {
describe('iD.svgOsm', function () {
var container;
beforeEach(function () {
@@ -6,7 +6,7 @@ describe('iD.svg.Osm', function () {
});
it('creates default osm layers', function () {
container.call(iD.svg.Osm());
container.call(iD.svgOsm());
var nodes = container.selectAll('.layer-osm').nodes();
expect(nodes.length).to.eql(5);
expect(d3.select(nodes[0])).to.be.classed('layer-areas');
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Points', function () {
describe('iD.svgPoints', function () {
var context, surface,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -18,7 +18,7 @@ describe('iD.svg.Points', function () {
var point = iD.Node({tags: {amenity: 'cafe'}, loc: [0, 0]}),
graph = iD.Graph([point]);
surface.call(iD.svg.Points(projection, context), graph, [point]);
surface.call(iD.svgPoints(projection, context), graph, [point]);
expect(surface.select('.point')).to.be.classed('tag-amenity');
expect(surface.select('.point')).to.be.classed('tag-amenity-cafe');
+3 -3
View File
@@ -1,11 +1,11 @@
describe('iD.svg.RelationMemberTags', function() {
describe('iD.svgRelationMemberTags', function() {
it('includes tags from parent multipolygon relations', function() {
var graph = iD.Graph([
iD.Way({id: 'w'}),
iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'multipolygon'}})
]);
expect(iD.svg.RelationMemberTags(graph)(graph.entity('w')))
expect(iD.svgRelationMemberTags(graph)(graph.entity('w')))
.to.eql({type: 'multipolygon'});
});
@@ -15,7 +15,7 @@ describe('iD.svg.RelationMemberTags', function() {
iD.Relation({id: 'r', members: [{id: 'w'}], tags: {type: 'boundary'}})
]);
expect(iD.svg.RelationMemberTags(graph)(graph.entity('w')))
expect(iD.svgRelationMemberTags(graph)(graph.entity('w')))
.to.eql({type: 'boundary'});
});
});
+29 -29
View File
@@ -1,4 +1,4 @@
describe('iD.svg.TagClasses', function () {
describe('iD.svgTagClasses', function () {
var selection;
beforeEach(function () {
@@ -8,156 +8,156 @@ describe('iD.svg.TagClasses', function () {
it('adds no classes to elements whose datum has no tags', function() {
selection
.datum(iD.Entity())
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal(null);
});
it('adds classes for primary tag key and key-value', function() {
selection
.datum(iD.Entity({tags: {highway: 'primary'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-highway tag-highway-primary');
});
it('adds only one primary tag', function() {
selection
.datum(iD.Entity({tags: {highway: 'primary', railway: 'rail'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-highway tag-highway-primary');
});
it('orders primary tags', function() {
selection
.datum(iD.Entity({tags: {railway: 'rail', highway: 'primary'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-highway tag-highway-primary');
});
it('adds status tag when status in primary value (`railway=abandoned`)', function() {
selection
.datum(iD.Entity({tags: {railway: 'abandoned'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-railway tag-status tag-status-abandoned');
});
it('adds status tag when status in key and value matches "yes" (railway=rail + abandoned=yes)', function() {
selection
.datum(iD.Entity({tags: {railway: 'rail', abandoned: 'yes'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-railway tag-railway-rail tag-status tag-status-abandoned');
});
it('adds status tag when status in key and value matches primary (railway=rail + abandoned=railway)', function() {
selection
.datum(iD.Entity({tags: {railway: 'rail', abandoned: 'railway'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-railway tag-railway-rail tag-status tag-status-abandoned');
});
it('adds primary and status tag when status in key and no primary (abandoned=railway)', function() {
selection
.datum(iD.Entity({tags: {abandoned: 'railway'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-railway tag-status tag-status-abandoned');
});
it('does not add status tag for different primary tag (highway=path + abandoned=railway)', function() {
selection
.datum(iD.Entity({tags: {highway: 'path', abandoned: 'railway'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-highway tag-highway-path');
});
it('adds secondary tags', function() {
selection
.datum(iD.Entity({tags: {highway: 'primary', bridge: 'yes'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('tag-highway tag-highway-primary tag-bridge tag-bridge-yes');
});
it('adds no bridge=no tags', function() {
selection
.datum(iD.Entity({tags: {bridge: 'no'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal(null);
});
it('adds tag-unpaved for highway=track with no surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'track'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).to.be.classed('tag-unpaved');
});
it('does not add tag-unpaved for highway=track with explicit paved surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'track', surface: 'asphalt'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {highway: 'track', tracktype: 'grade1'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
});
it('adds tag-unpaved for highway=track with explicit unpaved surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'track', surface: 'dirt'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {highway: 'track', tracktype: 'grade3'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).to.be.classed('tag-unpaved');
});
it('does not add tag-unpaved for other highway types with no surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'tertiary'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {highway: 'foo'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
});
it('does not add tag-unpaved for other highway types with explicit paved surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'tertiary', surface: 'asphalt'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {highway: 'foo', tracktype: 'grade1'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
});
it('adds tag-unpaved for other highway types with explicit unpaved surface tagging', function() {
selection
.datum(iD.Entity({tags: {highway: 'tertiary', surface: 'dirt'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {highway: 'foo', tracktype: 'grade3'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).to.be.classed('tag-unpaved');
});
it('does not add tag-unpaved for non-highways', function() {
selection
.datum(iD.Entity({tags: {railway: 'abandoned', surface: 'gravel'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
selection
.datum(iD.Entity({tags: {amenity: 'parking', surface: 'dirt'}}))
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection).not.to.be.classed('tag-unpaved');
});
@@ -165,7 +165,7 @@ describe('iD.svg.TagClasses', function () {
var primary = function () { return { highway: 'primary'}; };
selection
.datum(iD.Entity())
.call(iD.svg.TagClasses().tags(primary));
.call(iD.svgTagClasses().tags(primary));
expect(selection.attr('class')).to.equal('tag-highway tag-highway-primary');
});
@@ -173,7 +173,7 @@ describe('iD.svg.TagClasses', function () {
selection
.attr('class', 'tag-highway tag-highway-primary')
.datum(iD.Entity())
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('');
});
@@ -181,7 +181,7 @@ describe('iD.svg.TagClasses', function () {
selection
.attr('class', 'selected')
.datum(iD.Entity())
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal('selected');
});
@@ -189,7 +189,7 @@ describe('iD.svg.TagClasses', function () {
selection = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
selection
.datum(iD.Entity())
.call(iD.svg.TagClasses());
.call(iD.svgTagClasses());
expect(selection.attr('class')).to.equal(null);
});
});
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.svg.Vertices', function () {
describe('iD.svgVertices', function () {
var context, surface,
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
.translate([0, 0])
@@ -20,7 +20,7 @@ describe('iD.svg.Vertices', function () {
way2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}),
graph = iD.Graph([node, way1, way2]);
surface.call(iD.svg.Vertices(projection, context), graph, [node], 17);
surface.call(iD.svgVertices(projection, context), graph, [node], 17);
expect(surface.select('.vertex')).to.be.classed('shared');
});
+12 -12
View File
@@ -1,4 +1,4 @@
describe('iD.ui.cmd', function () {
describe('iD.uiCmd', function () {
var orig,
ua = navigator.userAgent,
isPhantom = (navigator.userAgent.match(/PhantomJS/) !== null),
@@ -28,29 +28,29 @@ describe('iD.ui.cmd', function () {
it('does not overwrite mac keybindings', function () {
ua = 'Mac';
expect(iD.ui.cmd('⌘A')).to.eql('⌘A');
expect(iD.uiCmd('⌘A')).to.eql('⌘A');
});
it('changes keys to linux versions', function () {
ua = 'Linux';
expect(iD.ui.cmd('⌘A')).to.eql('Ctrl+A');
expect(iD.ui.cmd('⇧A')).to.eql('Shift+A');
expect(iD.ui.cmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
expect(iD.ui.cmd('⌘⇧Z')).to.eql('Ctrl+Shift+Z');
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
expect(iD.uiCmd('⌘⇧Z')).to.eql('Ctrl+Shift+Z');
});
it('changes keys to win versions', function () {
ua = 'Win';
expect(iD.ui.cmd('⌘A')).to.eql('Ctrl+A');
expect(iD.ui.cmd('⇧A')).to.eql('Shift+A');
expect(iD.ui.cmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
expect(iD.ui.cmd('⌘⇧Z')).to.eql('Ctrl+Y'); // special case
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
expect(iD.uiCmd('⌘⇧Z')).to.eql('Ctrl+Y'); // special case
});
it('handles multi-character keys', function () {
ua = 'Win';
expect(iD.ui.cmd('f11')).to.eql('f11');
expect(iD.ui.cmd('⌘plus')).to.eql('Ctrl+plus');
expect(iD.uiCmd('f11')).to.eql('f11');
expect(iD.uiCmd('⌘plus')).to.eql('Ctrl+plus');
});
});
+3 -3
View File
@@ -1,17 +1,17 @@
describe('iD.ui.confirm', function () {
describe('iD.uiConfirm', function () {
var elem;
beforeEach(function() { elem = d3.select('body').append('div'); });
afterEach(function() { elem.remove(); });
it('can be instantiated', function () {
var confirm = iD.ui.uiconfirm(elem);
var confirm = iD.uiConfirm(elem);
expect(confirm).to.be.ok;
happen.keydown(document, {keyCode: 27}); // dismiss
});
it('can be dismissed', function (done) {
var confirm = iD.ui.uiconfirm(elem);
var confirm = iD.uiConfirm(elem);
happen.click(confirm.select('button').node());
window.setTimeout(function() {
expect(confirm.node().parentNode).to.be.null;
+13 -13
View File
@@ -1,13 +1,13 @@
describe('iD.ui.fields.access', function() {
describe('iD.uiFieldAccess', function() {
var selection, field;
beforeEach(function() {
selection = d3.select(document.createElement('div'));
field = iD.Context(window)
.presets(iD.data.presets).presets().field('access');
.presets(iD.dataPresets).presets().field('access');
});
it('creates inputs for a variety of modes of access', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
expect(selection.selectAll('.preset-access-access').size()).to.equal(1);
expect(selection.selectAll('.preset-access-foot').size()).to.equal(1);
@@ -17,20 +17,20 @@ describe('iD.ui.fields.access', function() {
});
it('does not include "yes", "designated", "dismount" options for general access (#934), (#2213)', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
expect(_.map(access.options('access'), 'value')).not.to.include('yes');
expect(_.map(access.options('access'), 'value')).not.to.include('designated');
expect(_.map(access.options('access'), 'value')).not.to.include('dismount');
});
it('does include a "dismount" option for bicycles (#2726)', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
expect(_.map(access.options('bicycle'), 'value')).to.include('dismount');
expect(_.map(access.options('foot'), 'value')).not.to.include('dismount');
});
it('sets foot placeholder to "yes" for steps and pedestrian', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'steps'});
@@ -41,7 +41,7 @@ describe('iD.ui.fields.access', function() {
});
it('sets foot placeholder to "designated" for footways', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'footway'});
@@ -49,7 +49,7 @@ describe('iD.ui.fields.access', function() {
});
it('sets bicycle placeholder to "designated" for cycleways', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'cycleway'});
@@ -57,7 +57,7 @@ describe('iD.ui.fields.access', function() {
});
it('sets horse placeholder to "designated" for bridleways', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'bridleway'});
@@ -65,7 +65,7 @@ describe('iD.ui.fields.access', function() {
});
it('sets motor_vehicle placeholder to "no" for footways, steps, pedestrian, cycleway, bridleway, and path', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
['footway', 'steps', 'pedestrian', 'cycleway', 'bridleway', 'path'].forEach(function(value) {
access.tags({highway: value});
@@ -74,7 +74,7 @@ describe('iD.ui.fields.access', function() {
});
it('sets motor_vehicle placeholder to "yes" for various other highway tags', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
['residential', 'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'service',
'unclassified', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link'].forEach(function(value) {
@@ -84,7 +84,7 @@ describe('iD.ui.fields.access', function() {
});
it('overrides a "yes" or "designated" placeholder with more specific access tag (#2213)', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'service', access: 'emergency'});
@@ -95,7 +95,7 @@ describe('iD.ui.fields.access', function() {
});
it('overrides a "no" placeholder with more specific access tag (#2763)', function() {
var access = iD.ui.fields.access(field);
var access = iD.uiFieldAccess(field);
selection.call(access);
access.tags({highway: 'cycleway', access: 'destination'});
+20 -20
View File
@@ -1,13 +1,13 @@
describe('iD.ui.fields.localized', function() {
describe('iD.uiFieldLocalized', function() {
var selection, field;
beforeEach(function() {
selection = d3.select(document.createElement('div'));
field = iD.presets.Field('test', {key: 'name'});
field = iD.presetField('test', {key: 'name'});
});
it('adds a blank set of fields when the + button is clicked', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
expect(selection.selectAll('.localized-lang').nodes().length).to.equal(1);
@@ -15,7 +15,7 @@ describe('iD.ui.fields.localized', function() {
});
it('doesn\'t create a tag when the value is empty', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -23,13 +23,13 @@ describe('iD.ui.fields.localized', function() {
expect(tags).to.eql({});
});
iD.util.getSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
iD.utilGetSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
happen.once(selection.selectAll('.localized-lang').node(), {type: 'blur'});
});
it('doesn\'t create a tag when the name is empty', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -37,45 +37,45 @@ describe('iD.ui.fields.localized', function() {
expect(tags).to.eql({});
});
iD.util.getSetValue(selection.selectAll('.localized-value'), 'Value');
iD.utilGetSetValue(selection.selectAll('.localized-value'), 'Value');
happen.once(selection.selectAll('.localized-value').node(), {type: 'change'});
happen.once(selection.selectAll('.localized-value').node(), {type: 'blur'});
});
it('creates a tag after setting language then value', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
iD.util.getSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
iD.utilGetSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
localized.on('change', function(tags) {
expect(tags).to.eql({'name:de': 'Value'});
});
iD.util.getSetValue(selection.selectAll('.localized-value'), 'Value');
iD.utilGetSetValue(selection.selectAll('.localized-value'), 'Value');
happen.once(selection.selectAll('.localized-value').node(), {type: 'change'});
});
it('creates a tag after setting value then language', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
iD.util.getSetValue(selection.selectAll('.localized-value'), 'Value');
iD.utilGetSetValue(selection.selectAll('.localized-value'), 'Value');
happen.once(selection.selectAll('.localized-value').node(), {type: 'change'});
localized.on('change', function(tags) {
expect(tags).to.eql({'name:de': 'Value'});
});
iD.util.getSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
iD.utilGetSetValue(selection.selectAll('.localized-lang'), 'Deutsch');
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
});
it('changes an existing language', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -85,12 +85,12 @@ describe('iD.ui.fields.localized', function() {
'name:en': 'Value'});
});
iD.util.getSetValue(selection.selectAll('.localized-lang'), 'English');
iD.utilGetSetValue(selection.selectAll('.localized-lang'), 'English');
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
});
it('ignores similar keys like `old_name`', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
localized.tags({'old_name:de': 'Value'});
@@ -99,7 +99,7 @@ describe('iD.ui.fields.localized', function() {
});
it('removes the tag when the language is emptied', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -107,12 +107,12 @@ describe('iD.ui.fields.localized', function() {
expect(tags).to.eql({'name:de': undefined});
});
iD.util.getSetValue(selection.selectAll('.localized-lang'), '');
iD.utilGetSetValue(selection.selectAll('.localized-lang'), '');
happen.once(selection.selectAll('.localized-lang').node(), {type: 'change'});
});
it('removes the tag when the value is emptied', function() {
var localized = iD.ui.fields.localized(field, {});
var localized = iD.uiFieldLocalized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -120,7 +120,7 @@ describe('iD.ui.fields.localized', function() {
expect(tags).to.eql({'name:de': undefined});
});
iD.util.getSetValue(selection.selectAll('.localized-value'), '');
iD.utilGetSetValue(selection.selectAll('.localized-value'), '');
happen.once(selection.selectAll('.localized-value').node(), {type: 'change'});
});
});
+24 -24
View File
@@ -1,11 +1,11 @@
describe('iD.ui.fields.wikipedia', function() {
describe('iD.uiFieldWikipedia', function() {
var entity, context, selection, field, selectedId;
function changeTags(changed) {
var annotation = 'Changed tags.';
var tags = _.extend({}, entity.tags, changed);
context.perform(iD.actions.ChangeTags(entity.id, tags), annotation);
context.perform(iD.actionChangeTags(entity.id, tags), annotation);
}
beforeEach(function() {
@@ -14,7 +14,7 @@ describe('iD.ui.fields.wikipedia', function() {
context = iD.Context(window);
context.history().merge([entity]);
selection = d3.select(document.createElement('div'));
field = context.presets(iD.data.presets).presets().field('wikipedia');
field = context.presets(iD.dataPresets).presets().field('wikipedia');
window.JSONP_DELAY = 0;
window.JSONP_FIX = {
entities: {
@@ -31,22 +31,22 @@ describe('iD.ui.fields.wikipedia', function() {
});
it('recognizes lang:title format', function() {
var wikipedia = iD.ui.fields.wikipedia(field, context);
var wikipedia = iD.uiFieldWikipedia(field, context);
selection.call(wikipedia);
wikipedia.tags({wikipedia: 'en:Title'});
expect(iD.util.getSetValue(selection.selectAll('.wiki-lang'))).to.equal('English');
expect(iD.util.getSetValue(selection.selectAll('.wiki-title'))).to.equal('Title');
expect(iD.utilGetSetValue(selection.selectAll('.wiki-lang'))).to.equal('English');
expect(iD.utilGetSetValue(selection.selectAll('.wiki-title'))).to.equal('Title');
expect(selection.selectAll('.wiki-link').attr('href')).to.equal('https://en.wikipedia.org/wiki/Title');
});
it('sets language, value, wikidata', function() {
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
var wikipedia = iD.uiFieldWikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
var spy = sinon.spy();
wikipedia.on('change.spy', spy);
iD.util.getSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
iD.utilGetSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
happen.once(selection.selectAll('.wiki-lang').node(), { type: 'change' });
happen.once(selection.selectAll('.wiki-lang').node(), { type: 'blur' });
expect(spy.callCount).to.equal(2);
@@ -55,7 +55,7 @@ describe('iD.ui.fields.wikipedia', function() {
spy = sinon.spy();
wikipedia.on('change.spy', spy);
iD.util.getSetValue(selection.selectAll('.wiki-title'), 'Title');
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' });
expect(spy.callCount).to.equal(3);
@@ -65,42 +65,42 @@ describe('iD.ui.fields.wikipedia', function() {
});
it('recognizes pasted URLs', function() {
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
var wikipedia = iD.uiFieldWikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
iD.util.getSetValue(selection.selectAll('.wiki-title'), 'http://de.wikipedia.org/wiki/Title');
iD.utilGetSetValue(selection.selectAll('.wiki-title'), 'http://de.wikipedia.org/wiki/Title');
happen.once(selection.selectAll('.wiki-title').node(), { type: 'change' });
expect(iD.util.getSetValue(selection.selectAll('.wiki-lang'))).to.equal('Deutsch');
expect(iD.util.getSetValue(selection.selectAll('.wiki-title'))).to.equal('Title');
expect(iD.utilGetSetValue(selection.selectAll('.wiki-lang'))).to.equal('Deutsch');
expect(iD.utilGetSetValue(selection.selectAll('.wiki-title'))).to.equal('Title');
});
it('preserves existing language', function() {
selection.call(iD.ui.fields.wikipedia(field, context));
iD.util.getSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
selection.call(iD.uiFieldWikipedia(field, context));
iD.utilGetSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
var wikipedia = iD.ui.fields.wikipedia(field, context);
var wikipedia = iD.uiFieldWikipedia(field, context);
selection.call(wikipedia);
wikipedia.tags({});
expect(iD.util.getSetValue(selection.selectAll('.wiki-lang'))).to.equal('Deutsch');
expect(iD.utilGetSetValue(selection.selectAll('.wiki-lang'))).to.equal('Deutsch');
});
it('does not set delayed wikidata tag if wikipedia field has changed', function(done) {
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
var wikipedia = iD.uiFieldWikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
window.JSONP_DELAY = 20;
var spy = sinon.spy();
wikipedia.on('change.spy', spy);
iD.util.getSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
iD.util.getSetValue(selection.selectAll('.wiki-title'), 'Skip');
iD.utilGetSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
iD.utilGetSetValue(selection.selectAll('.wiki-title'), 'Skip');
happen.once(selection.selectAll('.wiki-title').node(), { type: 'change' });
happen.once(selection.selectAll('.wiki-title').node(), { type: 'blur' });
window.setTimeout(function() {
iD.util.getSetValue(selection.selectAll('.wiki-title'), 'Title');
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' });
}, 10);
@@ -118,15 +118,15 @@ describe('iD.ui.fields.wikipedia', function() {
});
it('does not set delayed wikidata tag if selected entity has changed', function(done) {
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
var wikipedia = iD.uiFieldWikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
window.JSONP_DELAY = 20;
var spy = sinon.spy();
wikipedia.on('change.spy', spy);
iD.util.getSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
iD.util.getSetValue(selection.selectAll('.wiki-title'), 'Title');
iD.utilGetSetValue(selection.selectAll('.wiki-lang'), 'Deutsch');
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' });
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.ui.flash', function () {
describe('iD.uiFlash', function () {
var clock;
var elem;
@@ -18,7 +18,7 @@ describe('iD.ui.flash', function () {
});
it('leaves after 1000 ms', function () {
var flash = iD.ui.flash(elem);
var flash = iD.uiFlash(elem);
clock.tick(1610);
expect(flash.node().parentNode).to.be.null;
});
+1 -1
View File
@@ -1,2 +1,2 @@
describe('iD.ui.Inspector', function () {
describe('iD.uiInspector', function () {
});
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.ui.modal', function () {
describe('iD.uiModal', function () {
var elem;
beforeEach(function() {
@@ -10,7 +10,7 @@ describe('iD.ui.modal', function () {
});
it('can be instantiated', function() {
var modal = iD.ui.modal(elem)
var modal = iD.uiModal(elem)
.select('.content')
.text('foo');
expect(modal).to.be.ok;
+3 -3
View File
@@ -1,9 +1,9 @@
describe('iD.ui.RawTagEditor', function() {
describe('iD.uiRawTagEditor', function() {
var taglist, element,
entity, context;
function render(tags) {
taglist = iD.ui.RawTagEditor(context)
taglist = iD.uiRawTagEditor(context)
.entityID(entity.id)
.preset({isFallback: function() { return false; }})
.tags(tags);
@@ -50,7 +50,7 @@ describe('iD.ui.RawTagEditor', function() {
expect(tags).to.eql({highway: undefined});
done();
});
iD.util.triggerEvent(element.selectAll('button.remove'), 'click');
iD.utilTriggerEvent(element.selectAll('button.remove'), 'click');
});
it('adds tags when pressing the TAB key on last input.value', function (done) {
+15 -15
View File
@@ -1,4 +1,4 @@
describe('iD.util.SessionMutex', function() {
describe('iD.utilSessionMutex', function() {
var clock, a, b;
beforeEach(function () {
@@ -13,39 +13,39 @@ describe('iD.util.SessionMutex', function() {
describe('#lock', function() {
it('returns true when it gets a lock', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
expect(a.lock()).to.equal(true);
});
it('returns true when already locked', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
expect(a.lock()).to.equal(true);
});
it('returns false when the lock is held by another session', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
b = iD.util.SessionMutex('name');
b = iD.utilSessionMutex('name');
expect(b.lock()).to.equal(false);
});
});
describe('#locked', function() {
it('returns false by default', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
expect(a.locked()).to.equal(false);
});
it('returns true when locked', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
expect(a.locked()).to.equal(true);
});
it('returns false when unlocked', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
a.unlock();
expect(a.locked()).to.equal(false);
@@ -54,36 +54,36 @@ describe('iD.util.SessionMutex', function() {
describe('#unlock', function() {
it('unlocks the mutex', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
a.unlock();
b = iD.util.SessionMutex('name');
b = iD.utilSessionMutex('name');
expect(b.lock()).to.equal(true);
});
it('does nothing when the lock is held by another session', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.lock();
b = iD.util.SessionMutex('name');
b = iD.utilSessionMutex('name');
b.unlock();
expect(a.locked()).to.equal(true);
});
it('does nothing when not locked', function() {
a = iD.util.SessionMutex('name');
a = iD.utilSessionMutex('name');
a.unlock();
expect(a.locked()).to.equal(false);
});
});
it('namespaces locks', function() {
a = iD.util.SessionMutex('a');
a = iD.utilSessionMutex('a');
a.lock();
b = iD.util.SessionMutex('b');
b = iD.utilSessionMutex('b');
expect(b.locked()).to.equal(false);
expect(b.lock()).to.equal(true);
});
+2 -2
View File
@@ -1,4 +1,4 @@
describe('iD.util.SuggestNames', function() {
describe('iD.utilSuggestNames', function() {
var suggestions = {
'key': {
'value': {
@@ -12,7 +12,7 @@ describe('iD.util.SuggestNames', function() {
'id': 'key/value'
};
var a = iD.util.SuggestNames(preset, suggestions);
var a = iD.utilSuggestNames(preset, suggestions);
it('provides suggestions for an entered value', function(done) {
a('abcd', function(result) {
+24 -24
View File
@@ -1,50 +1,50 @@
describe('iD.Util', function() {
it('#tagText', function() {
expect(iD.util.tagText({})).to.eql('');
expect(iD.util.tagText({tags:{foo:'bar'}})).to.eql('foo=bar');
expect(iD.util.tagText({tags:{foo:'bar',two:'three'}})).to.eql('foo=bar, two=three');
describe('iD.util', function() {
it('utilTagText', function() {
expect(iD.utilTagText({})).to.eql('');
expect(iD.utilTagText({tags:{foo:'bar'}})).to.eql('foo=bar');
expect(iD.utilTagText({tags:{foo:'bar',two:'three'}})).to.eql('foo=bar, two=three');
});
it('#stringQs', function() {
expect(iD.util.stringQs('foo=bar')).to.eql({foo: 'bar'});
expect(iD.util.stringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
expect(iD.util.stringQs('')).to.eql({});
it('utilStringQs', function() {
expect(iD.utilStringQs('foo=bar')).to.eql({foo: 'bar'});
expect(iD.utilStringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
expect(iD.utilStringQs('')).to.eql({});
});
it('#qsString', function() {
expect(iD.util.qsString({ foo: 'bar' })).to.eql('foo=bar');
expect(iD.util.qsString({ foo: 'bar', one: 2 })).to.eql('foo=bar&one=2');
expect(iD.util.qsString({})).to.eql('');
it('utilQsString', function() {
expect(iD.utilQsString({ foo: 'bar' })).to.eql('foo=bar');
expect(iD.utilQsString({ foo: 'bar', one: 2 })).to.eql('foo=bar&one=2');
expect(iD.utilQsString({})).to.eql('');
});
it('#getPrototypeOf', function() {
it('utilGetPrototypeOf', function() {
var a = function() {};
a.prototype = { foo: 'foo' };
expect(iD.util.getPrototypeOf({})).to.eql({});
expect(iD.util.getPrototypeOf(new a())).to.eql({ foo: 'foo' });
expect(iD.utilGetPrototypeOf({})).to.eql({});
expect(iD.utilGetPrototypeOf(new a())).to.eql({ foo: 'foo' });
});
describe('#editDistance', function() {
describe('utilEditDistance', function() {
it('returns zero for same strings', function() {
expect(iD.util.editDistance('foo', 'foo')).to.eql(0);
expect(iD.utilEditDistance('foo', 'foo')).to.eql(0);
});
it('reports an insertion of 1', function() {
expect(iD.util.editDistance('foo', 'fooa')).to.eql(1);
expect(iD.utilEditDistance('foo', 'fooa')).to.eql(1);
});
it('reports a replacement of 1', function() {
expect(iD.util.editDistance('foob', 'fooa')).to.eql(1);
expect(iD.utilEditDistance('foob', 'fooa')).to.eql(1);
});
it('does not fail on empty input', function() {
expect(iD.util.editDistance('', '')).to.eql(0);
expect(iD.utilEditDistance('', '')).to.eql(0);
});
});
describe('#asyncMap', function() {
describe('utilAsyncMap', function() {
it('handles correct replies', function() {
iD.util.asyncMap([1, 2, 3],
iD.utilAsyncMap([1, 2, 3],
function(d, c) { c(null, d * 2); },
function(err, res) {
expect(err).to.eql([null, null, null]);
@@ -52,7 +52,7 @@ describe('iD.Util', function() {
});
});
it('handles errors', function() {
iD.util.asyncMap([1, 2, 3],
iD.utilAsyncMap([1, 2, 3],
function(d, c) { c('whoops ' + d, null); },
function(err, res) {
expect(err).to.eql(['whoops 1', 'whoops 2', 'whoops 3']);