Migrating to lodash v4

This commit is contained in:
Kushan Joshi
2016-05-16 13:31:29 +05:30
parent 4c88196c93
commit 6ef52256f3
50 changed files with 4478 additions and 3169 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ describe("iD.actions.AddMember", function() {
describe("inserts way members at a sensible index", function() {
function members(graph) {
return _.pluck(graph.entity('r').members, 'id');
return _.map(graph.entity('r').members, 'id');
}
specify("no members", function() {
+3 -3
View File
@@ -2,7 +2,7 @@ describe("iD.actions.Circularize", function () {
var projection = d3.geo.mercator();
function isCircular(id, graph) {
var points = _.pluck(graph.childNodes(graph.entity(id)), 'loc').map(projection),
var points = _.map(graph.childNodes(graph.entity(id)), 'loc').map(projection),
centroid = d3.geom.polygon(points).centroid(),
radius = iD.geo.euclideanDistance(centroid, points[0]),
estArea = Math.PI * radius * radius,
@@ -105,7 +105,7 @@ describe("iD.actions.Circularize", function () {
graph = iD.actions.Circularize('-', projection, 20)(graph);
expect(isCircular('-', graph)).to.be.ok;
points = _.pluck(graph.childNodes(graph.entity('-')), 'loc').map(projection);
points = _.map(graph.childNodes(graph.entity('-')), 'loc').map(projection);
centroid = d3.geom.polygon(points).centroid();
for (var i = 0; i < points.length - 1; i++) {
@@ -116,7 +116,7 @@ describe("iD.actions.Circularize", function () {
});
function area(id, graph) {
return d3.geom.polygon(_.pluck(graph.childNodes(graph.entity(id)), 'loc')).area();
return d3.geom.polygon(_.map(graph.childNodes(graph.entity(id)), 'loc')).area();
}
it("leaves clockwise ways clockwise", function () {
+1 -1
View File
@@ -11,7 +11,7 @@ describe("iD.actions.DeleteWay", function() {
relation = iD.Relation({members: [{ id: way.id }, { id: 'w-2' }]}),
action = iD.actions.DeleteWay(way.id),
graph = iD.Graph([way, relation]).update(action);
expect(_.pluck(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
expect(_.map(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
});
it("deletes member nodes not referenced by another parent", function() {
+3 -2
View File
@@ -93,14 +93,15 @@ describe("iD.actions.MergeRemoteChanges", function () {
describe("non-destuctive merging", function () {
describe("tags", function() {
it("doesn't merge tags if conflict (local change, remote change)", function () {
var localTags = {foo: 'foo_local'}, // changed foo
remoteTags = {foo: 'foo_remote'}, // changed foo
local = base.entity('a').update({tags: localTags}),
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
localGraph = makeGraph([local]),
remoteGraph = makeGraph([remote]),
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
result = action(localGraph);
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph);
var result = action(localGraph);
expect(result).to.eql(localGraph);
});
+4 -4
View File
@@ -377,7 +377,7 @@ describe("iD.actions.Split", function () {
graph = iD.actions.Split('b', ['='])(graph);
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['-', '=', '~']);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['-', '=', '~']);
});
it("adds the new way to parent relations (reverse order)", function () {
@@ -403,7 +403,7 @@ describe("iD.actions.Split", function () {
graph = iD.actions.Split('b', ['='])(graph);
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
});
it("handles incomplete relations", function () {
@@ -417,7 +417,7 @@ describe("iD.actions.Split", function () {
graph = iD.actions.Split('b', ['='])(graph);
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
});
it("converts simple multipolygon to a proper multipolygon", function () {
@@ -433,7 +433,7 @@ describe("iD.actions.Split", function () {
expect(graph.entity('-').tags).to.eql({});
expect(graph.entity('r').tags).to.eql({type: 'multipolygon', natural: 'water'});
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['-', '=']);
expect(_.map(graph.entity('r').members, 'id')).to.eql(['-', '=']);
});
['restriction', 'restriction:bus'].forEach(function (type) {
+2 -2
View File
@@ -190,9 +190,9 @@ describe("iD.Tree", function() {
graph = graph.replace(n1.move([1.1,1.1])).replace(n2.move([2.1,2.1]));
expect(
_.pluck(tree.intersects(extent, graph),'id').sort()
_.map(tree.intersects(extent, graph),'id').sort()
).to.eql(
_.pluck([n1, n2, way],'id').sort()
_.map([n1, n2, way],'id').sort()
);
});
+3 -3
View File
@@ -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(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
});
it("excludes coincident 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(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
});
it('excludes area highways', function() {
@@ -59,7 +59,7 @@ describe("iD.geo.Intersection", function() {
iD.Node({id: 'w'}),
iD.Way({id: '=', nodes: ['u', '*', 'w'], tags: {highway: 'residential'}})
]);
expect(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
});
});
+1 -1
View File
@@ -73,7 +73,7 @@ describe("iD.geo.joinWays", function() {
]);
var result = iD.geo.joinWays(graph.entity('r').members, graph);
expect(_.pluck(result[0], 'id')).to.eql(['=', '-', '~']);
expect(_.map(result[0], 'id')).to.eql(['=', '-', '~']);
});
it("reverses member tags of reversed segements", function() {
+5 -5
View File
@@ -18,15 +18,15 @@ describe('iD.ui.preset.access', function() {
it('does not include "yes", "designated", "dismount" options for general access (#934), (#2213)', function() {
var access = iD.ui.preset.access(field);
expect(_.pluck(access.options('access'), 'value')).not.to.include('yes');
expect(_.pluck(access.options('access'), 'value')).not.to.include('designated');
expect(_.pluck(access.options('access'), 'value')).not.to.include('dismount');
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.preset.access(field);
expect(_.pluck(access.options('bicycle'), 'value')).to.include('dismount');
expect(_.pluck(access.options('foot'), 'value')).not.to.include('dismount');
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() {