mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Fix tests and lint warnings
This commit is contained in:
@@ -36,9 +36,9 @@ export function coreValidator(context) {
|
||||
}
|
||||
}
|
||||
|
||||
self.featureApplicabilityOptions = ['edited', 'all'];
|
||||
//self.featureApplicabilityOptions = ['edited', 'all'];
|
||||
|
||||
var featureApplicability = context.storage('issue-features') || 'edited';
|
||||
/*var featureApplicability = context.storage('issue-features') || 'edited';
|
||||
|
||||
self.getFeatureApplicability = function() {
|
||||
return featureApplicability;
|
||||
@@ -47,7 +47,7 @@ export function coreValidator(context) {
|
||||
self.setFeatureApplicability = function(applicability) {
|
||||
featureApplicability = applicability;
|
||||
context.storage('issue-features', applicability);
|
||||
};
|
||||
};*/
|
||||
|
||||
self.getIssues = function() {
|
||||
return issues;
|
||||
@@ -180,7 +180,7 @@ export function validationIssue(attrs) {
|
||||
return osmEntity.key(entity);
|
||||
});
|
||||
// factor in the entities this issue is for
|
||||
id += entityKeys.join();
|
||||
id += entityKeys.sort().join();
|
||||
if (this.coordinates) {
|
||||
// factor in coordinates since two separate issues can have an
|
||||
// idential type and entities, e.g. in crossing_ways
|
||||
|
||||
@@ -16,7 +16,7 @@ import { uiTooltipHtml } from './tooltipHtml';
|
||||
|
||||
export function uiIssues(context) {
|
||||
var key = t('issues.key');
|
||||
var _featureApplicabilityList = d3_select(null);
|
||||
//var _featureApplicabilityList = d3_select(null);
|
||||
var _errorsList = d3_select(null),
|
||||
_warningsList = d3_select(null);
|
||||
var pane = d3_select(null);
|
||||
@@ -24,7 +24,7 @@ export function uiIssues(context) {
|
||||
|
||||
context.validator().on('reload.issues_pane', update);
|
||||
|
||||
function renderIssuesOptions(selection) {
|
||||
/*function renderIssuesOptions(selection) {
|
||||
var container = selection.selectAll('.issues-options-container')
|
||||
.data([0]);
|
||||
|
||||
@@ -42,7 +42,7 @@ export function uiIssues(context) {
|
||||
.merge(_featureApplicabilityList);
|
||||
|
||||
updateFeatureApplicabilityList();
|
||||
}
|
||||
}*/
|
||||
|
||||
function renderErrorsList(selection) {
|
||||
_errorsList = selection.selectAll('.errors-list')
|
||||
@@ -68,7 +68,7 @@ export function uiIssues(context) {
|
||||
updateWarningsList();
|
||||
}
|
||||
|
||||
function drawListItems(selection, data, type, name, change, active) {
|
||||
/*function drawListItems(selection, data, type, name, change, active) {
|
||||
var items = selection.selectAll('li')
|
||||
.data(data);
|
||||
|
||||
@@ -109,7 +109,7 @@ export function uiIssues(context) {
|
||||
.classed('active', active)
|
||||
.selectAll('input')
|
||||
.property('checked', active);
|
||||
}
|
||||
}*/
|
||||
|
||||
function drawIssuesList(selection, issues) {
|
||||
|
||||
@@ -186,7 +186,7 @@ export function uiIssues(context) {
|
||||
noIssuesLabel.append('span')
|
||||
.text(t('issues.no_issues.info'));
|
||||
}
|
||||
|
||||
/*
|
||||
function showsFeatureApplicability(d) {
|
||||
return context.validator().getFeatureApplicability() === d;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ export function uiIssues(context) {
|
||||
setFeatureApplicability,
|
||||
showsFeatureApplicability
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
function updateErrorsList() {
|
||||
var errors = context.validator().getErrors();
|
||||
@@ -226,7 +226,7 @@ export function uiIssues(context) {
|
||||
pane.select('.issues-errors').classed('hide', errors.length === 0);
|
||||
if (errors.length > 0) {
|
||||
pane.select('.hide-toggle-issues_errors .hide-toggle-text')
|
||||
.text(t('issues.errors.list_title', { count: errors.length }))
|
||||
.text(t('issues.errors.list_title', { count: errors.length }));
|
||||
if (!pane.select('.disclosure-wrap-issues_errors').classed('hide')) {
|
||||
updateErrorsList();
|
||||
}
|
||||
@@ -236,7 +236,7 @@ export function uiIssues(context) {
|
||||
pane.select('.issues-warnings').classed('hide', warnings.length === 0);
|
||||
if (warnings.length > 0) {
|
||||
pane.select('.hide-toggle-issues_warnings .hide-toggle-text')
|
||||
.text(t('issues.warnings.list_title', { count: warnings.length }))
|
||||
.text(t('issues.warnings.list_title', { count: warnings.length }));
|
||||
if (!pane.select('.disclosure-wrap-issues_warnings').classed('hide')) {
|
||||
updateWarningsList();
|
||||
}
|
||||
@@ -328,7 +328,7 @@ export function uiIssues(context) {
|
||||
content
|
||||
.append('div')
|
||||
.attr('class', 'issues-none')
|
||||
.call(renderNoIssuesBox)
|
||||
.call(renderNoIssuesBox);
|
||||
|
||||
// errors
|
||||
content
|
||||
|
||||
@@ -191,7 +191,7 @@ export function validationCrossingWays() {
|
||||
|
||||
if (highwaysDisallowingFords.has(entity1.tags.highway) ||
|
||||
highwaysDisallowingFords.has(entity2.tags.highway)) {
|
||||
// do not allow fords on major highways
|
||||
// do not allow fords on major highways
|
||||
return null;
|
||||
}
|
||||
return { ford: 'yes' };
|
||||
@@ -278,96 +278,97 @@ export function validationCrossingWays() {
|
||||
}
|
||||
return [];
|
||||
}));
|
||||
for (var i = 0; i < waysToCheck.length; i++) {
|
||||
var crosses = findCrossingsByWay(waysToCheck[i], graph, tree, edgePairsVisited);
|
||||
for (var j = 0; j < crosses.length; j++) {
|
||||
var crossing = crosses[j];
|
||||
var crossings = waysToCheck.reduce(function(array, way) {
|
||||
return array.concat(findCrossingsByWay(way, graph, tree, edgePairsVisited));
|
||||
}, []);
|
||||
for (var j in crossings) {
|
||||
var crossing = crossings[j];
|
||||
|
||||
// use the entities with the tags that define the feature type
|
||||
var entities = crossing.ways.sort(function(entity1, entity2) {
|
||||
var type1 = getFeatureTypeForCrossingCheck(entity1, graph);
|
||||
var type2 = getFeatureTypeForCrossingCheck(entity2, graph);
|
||||
if (type1 === type2) {
|
||||
return utilDisplayLabel(entity1, context) > utilDisplayLabel(entity2, context);
|
||||
} else if (type1 === 'waterway') {
|
||||
return true;
|
||||
} else if (type2 === 'waterway') {
|
||||
return false;
|
||||
}
|
||||
return type1 < type2;
|
||||
});
|
||||
entities = _map(entities, function(way) {
|
||||
return getFeatureWithFeatureTypeTagsForWay(way, graph);
|
||||
});
|
||||
|
||||
var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1]);
|
||||
|
||||
var crossingTypeID;
|
||||
if (hasTag(entities[0].tags, 'tunnel') && hasTag(entities[1].tags, 'tunnel')) {
|
||||
crossingTypeID = 'tunnel-tunnel';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else if (hasTag(entities[0].tags, 'bridge') && hasTag(entities[1].tags, 'bridge')) {
|
||||
crossingTypeID = 'bridge-bridge';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else {
|
||||
crossingTypeID = crossing.featureTypes.sort().join('-');
|
||||
// use the entities with the tags that define the feature type
|
||||
var entities = crossing.ways.sort(function(entity1, entity2) {
|
||||
var type1 = getFeatureTypeForCrossingCheck(entity1, graph);
|
||||
var type2 = getFeatureTypeForCrossingCheck(entity2, graph);
|
||||
if (type1 === type2) {
|
||||
return utilDisplayLabel(entity1, context) > utilDisplayLabel(entity2, context);
|
||||
} else if (type1 === 'waterway') {
|
||||
return true;
|
||||
} else if (type2 === 'waterway') {
|
||||
return false;
|
||||
}
|
||||
return type1 < type2;
|
||||
});
|
||||
entities = _map(entities, function(way) {
|
||||
return getFeatureWithFeatureTypeTagsForWay(way, graph);
|
||||
});
|
||||
|
||||
var messageDict = {
|
||||
feature: utilDisplayLabel(entities[0], context),
|
||||
feature2: utilDisplayLabel(entities[1], context)
|
||||
};
|
||||
var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1]);
|
||||
|
||||
var fixes = [];
|
||||
var crossingTypeID;
|
||||
if (hasTag(entities[0].tags, 'tunnel') && hasTag(entities[1].tags, 'tunnel')) {
|
||||
crossingTypeID = 'tunnel-tunnel';
|
||||
if (connectionTags) {
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.add_connection_vertex.title'),
|
||||
onClick: function() {
|
||||
var loc = this.issue.coordinates;
|
||||
var ways = this.issue.info.ways;
|
||||
|
||||
context.perform(
|
||||
function actionConnectCrossingWays(graph) {
|
||||
var projection = context.projection;
|
||||
|
||||
var node = osmNode({ loc: loc, tags: connectionTags });
|
||||
graph = graph.replace(node);
|
||||
|
||||
var way0 = graph.entity(ways[0].id);
|
||||
var choice0 = geoChooseEdge(graph.childNodes(way0), projection(loc), projection);
|
||||
var edge0 = [way0.nodes[choice0.index - 1], way0.nodes[choice0.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge0}, node)(graph);
|
||||
|
||||
var way1 = graph.entity(ways[1].id);
|
||||
var choice1 = geoChooseEdge(graph.childNodes(way1), projection(loc), projection);
|
||||
var edge1 = [way1.nodes[choice1.index - 1], way1.nodes[choice1.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge1}, node)(graph);
|
||||
|
||||
return graph;
|
||||
},
|
||||
t('issues.fix.add_connection_vertex.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else if (hasTag(entities[0].tags, 'bridge') && hasTag(entities[1].tags, 'bridge')) {
|
||||
crossingTypeID = 'bridge-bridge';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else {
|
||||
crossingTypeID = crossing.featureTypes.sort().join('-');
|
||||
}
|
||||
|
||||
issues.push(new validationIssue({
|
||||
type: 'crossing_ways',
|
||||
severity: 'warning',
|
||||
message: t('issues.crossing_ways.message', messageDict),
|
||||
tooltip: t('issues.crossing_ways.'+crossingTypeID+'.tip'),
|
||||
entities: entities,
|
||||
info: {'ways': crossing.ways},
|
||||
coordinates: crossing.cross_point,
|
||||
fixes: fixes
|
||||
var messageDict = {
|
||||
feature: utilDisplayLabel(entities[0], context),
|
||||
feature2: utilDisplayLabel(entities[1], context)
|
||||
};
|
||||
|
||||
var fixes = [];
|
||||
if (connectionTags) {
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.add_connection_vertex.title'),
|
||||
onClick: function() {
|
||||
var loc = this.issue.coordinates;
|
||||
var ways = this.issue.info.ways;
|
||||
var connectionTags = this.issue.info.connectionTags;
|
||||
|
||||
context.perform(
|
||||
function actionConnectCrossingWays(graph) {
|
||||
var projection = context.projection;
|
||||
|
||||
var node = osmNode({ loc: loc, tags: connectionTags });
|
||||
graph = graph.replace(node);
|
||||
|
||||
var way0 = graph.entity(ways[0].id);
|
||||
var choice0 = geoChooseEdge(graph.childNodes(way0), projection(loc), projection);
|
||||
var edge0 = [way0.nodes[choice0.index - 1], way0.nodes[choice0.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge0}, node)(graph);
|
||||
|
||||
var way1 = graph.entity(ways[1].id);
|
||||
var choice1 = geoChooseEdge(graph.childNodes(way1), projection(loc), projection);
|
||||
var edge1 = [way1.nodes[choice1.index - 1], way1.nodes[choice1.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge1}, node)(graph);
|
||||
|
||||
return graph;
|
||||
},
|
||||
t('issues.fix.add_connection_vertex.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
issues.push(new validationIssue({
|
||||
type: 'crossing_ways',
|
||||
severity: 'warning',
|
||||
message: t('issues.crossing_ways.message', messageDict),
|
||||
tooltip: t('issues.crossing_ways.'+crossingTypeID+'.tip'),
|
||||
entities: entities,
|
||||
info: { ways: crossing.ways, connectionTags: connectionTags },
|
||||
coordinates: crossing.cross_point,
|
||||
fixes: fixes
|
||||
}));
|
||||
}
|
||||
|
||||
return issues;
|
||||
|
||||
@@ -144,13 +144,13 @@
|
||||
<script src='spec/util/session_mutex.js'></script>
|
||||
<script src='spec/util/util.js'></script>
|
||||
|
||||
<script src='spec/validations/issue_manager.js'></script>
|
||||
<script src='spec/validations/validator.js'></script>
|
||||
<script src='spec/validations/deprecated_tag.js'></script>
|
||||
<script src='spec/validations/missing_tag.js'></script>
|
||||
<script src='spec/validations/disconnected_highway.js'></script>
|
||||
<script src='spec/validations/disconnected_way.js'></script>
|
||||
<script src='spec/validations/tag_suggests_area.js'></script>
|
||||
<script src='spec/validations/crossing_ways.js'></script>
|
||||
<script src='spec/validations/highway_almost_junction.js'></script>
|
||||
<script src='spec/validations/almost_junction.js'></script>
|
||||
|
||||
<script src='spec/operations/detach_node.js'></script>
|
||||
<script>
|
||||
|
||||
@@ -223,11 +223,14 @@ describe('iD.osmEntity', function () {
|
||||
|
||||
describe('#hasDeprecatedTags', function () {
|
||||
it('returns false if entity has no tags', function () {
|
||||
expect(iD.Entity().deprecatedTags()).to.eql({});
|
||||
expect(iD.Entity().deprecatedTags()).to.eql([]);
|
||||
});
|
||||
|
||||
it('returns true if entity has deprecated tags', function () {
|
||||
expect(iD.Entity({ tags: { barrier: 'wire_fence' } }).deprecatedTags()).to.eql({ barrier: 'wire_fence' });
|
||||
expect(iD.Entity({ tags: { amenity: 'swimming_pool' } }).deprecatedTags()).to.eql([{
|
||||
old: { amenity: 'swimming_pool' },
|
||||
replace: { leisure: 'swimming_pool' }
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe('iD.validations.highway_almost_junction', function () {
|
||||
describe('iD.validations.almost_junction', function () {
|
||||
var context;
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -127,9 +127,14 @@ describe('iD.validations.highway_almost_junction', function () {
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationHighwayAlmostJunction(context);
|
||||
var validator = iD.validationAlmostJunction();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph(), context.history().tree());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
it('has no errors on init', function() {
|
||||
@@ -142,7 +147,7 @@ describe('iD.validations.highway_almost_junction', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.highway_almost_junction);
|
||||
expect(issue.type).to.eql('almost_junction');
|
||||
expect(issue.entities).to.have.lengthOf(3);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
expect(issue.entities[1].id).to.eql('n-1');
|
||||
@@ -161,7 +166,7 @@ describe('iD.validations.highway_almost_junction', function () {
|
||||
expect(issue.info.cross_loc[1]).to.eql(0);
|
||||
|
||||
expect(issue.fixes).to.have.lengthOf(2);
|
||||
issue.fixes[0].action();
|
||||
issue.fixes[0].onClick();
|
||||
issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
@@ -171,7 +176,7 @@ describe('iD.validations.highway_almost_junction', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.highway_almost_junction);
|
||||
expect(issue.type).to.eql('almost_junction');
|
||||
expect(issue.entities).to.have.lengthOf(3);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
expect(issue.entities[1].id).to.eql('n-1');
|
||||
@@ -190,7 +195,7 @@ describe('iD.validations.highway_almost_junction', function () {
|
||||
expect(issue.info.cross_loc[1]).to.eql(0);
|
||||
|
||||
expect(issue.fixes).to.have.lengthOf(2);
|
||||
issue.fixes[1].action();
|
||||
issue.fixes[1].onClick();
|
||||
issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
@@ -53,41 +53,21 @@ describe('iD.validations.crossing_ways', function () {
|
||||
);
|
||||
}
|
||||
|
||||
function createHighwayCrossingRailway() {
|
||||
var n1 = iD.Node({id: 'n-1', loc: [1,1]});
|
||||
var n2 = iD.Node({id: 'n-2', loc: [2,2]});
|
||||
var w1 = iD.Way({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});
|
||||
|
||||
context.perform(
|
||||
iD.actionAddEntity(n1),
|
||||
iD.actionAddEntity(n2),
|
||||
iD.actionAddEntity(w1)
|
||||
);
|
||||
|
||||
var n3 = iD.Node({id: 'n-3', loc: [1,2]});
|
||||
var n4 = iD.Node({id: 'n-4', loc: [2,1]});
|
||||
var w2 = iD.Way({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { railway: 'rail' }});
|
||||
|
||||
context.perform(
|
||||
iD.actionAddEntity(n3),
|
||||
iD.actionAddEntity(n4),
|
||||
iD.actionAddEntity(w2)
|
||||
);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationHighwayCrossingOtherWays(context);
|
||||
var validator = iD.validationCrossingWays();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph(), context.history().tree());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
function verifySingleCrossingIssue(issues, crossEid) {
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
function verifySingleCrossingIssue(issues) {
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.crossing_ways);
|
||||
expect(issue.type).to.eql('crossing_ways');
|
||||
expect(issue.entities).to.have.lengthOf(2);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
expect(issue.entities[1].id).to.eql(crossEid);
|
||||
|
||||
expect(issue.coordinates).to.have.lengthOf(2);
|
||||
expect(issue.coordinates[0]).to.eql(1.5);
|
||||
@@ -214,22 +194,18 @@ describe('iD.validations.crossing_ways', function () {
|
||||
it('two cross points between two highways', function() {
|
||||
createWaysWithTwoCrossingPoint();
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(2);
|
||||
expect(issues).to.have.lengthOf(4);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.crossing_ways);
|
||||
expect(issue.type).to.eql('crossing_ways');
|
||||
expect(issue.entities).to.have.lengthOf(2);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
expect(issue.entities[1].id).to.eql('w-2');
|
||||
|
||||
expect(issue.coordinates).to.have.lengthOf(2);
|
||||
expect(issue.coordinates[0]).to.eql(1.5);
|
||||
expect(issue.coordinates[1]).to.eql(1.5);
|
||||
|
||||
issue = issues[1];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.crossing_ways);
|
||||
expect(issue.type).to.eql('crossing_ways');
|
||||
expect(issue.entities).to.have.lengthOf(2);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
expect(issue.entities[1].id).to.eql('w-2');
|
||||
|
||||
expect(issue.coordinates).to.have.lengthOf(2);
|
||||
expect(issue.coordinates[0]).to.eql(2.5);
|
||||
@@ -266,13 +242,9 @@ describe('iD.validations.crossing_ways', function () {
|
||||
);
|
||||
}
|
||||
|
||||
// warning crossing cases between way and relation
|
||||
it('one cross point between highway and water relation', function() {
|
||||
createWayAndRelationWithOneCrossingPoint({ highway: 'residential' }, { natural: 'water' });
|
||||
verifySingleCrossingIssue(validate(), 'r-1');
|
||||
});
|
||||
|
||||
it('one cross point between railway and building relation', function() {
|
||||
// warning crossing cases between way and relation
|
||||
it('one cross point between highway and building relation', function() {
|
||||
createWayAndRelationWithOneCrossingPoint({ highway: 'residential' }, { building: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'r-1');
|
||||
});
|
||||
|
||||
@@ -19,9 +19,14 @@ describe('iD.validations.deprecated_tag', function () {
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationDeprecatedTag(context);
|
||||
var validator = iD.validationDeprecatedTag();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
it('has no errors on init', function() {
|
||||
@@ -40,8 +45,8 @@ describe('iD.validations.deprecated_tag', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.deprecated_tags);
|
||||
expect(issue.severity).to.eql(iD.ValidationIssueSeverity.warning);
|
||||
expect(issue.type).to.eql('deprecated_tags');
|
||||
expect(issue.severity).to.eql('warning');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe('iD.validations.disconnected_highway', function () {
|
||||
describe('iD.validations.disconnected_way', function () {
|
||||
var context;
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -40,9 +40,14 @@ describe('iD.validations.disconnected_highway', function () {
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationDisconnectedHighway(context);
|
||||
var validator = iD.validationDisconnectedWay();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
it('has no errors on init', function() {
|
||||
@@ -55,8 +60,8 @@ describe('iD.validations.disconnected_highway', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.disconnected_highway);
|
||||
expect(issue.severity).to.eql(iD.ValidationIssueSeverity.warning);
|
||||
expect(issue.type).to.eql('disconnected_way');
|
||||
expect(issue.severity).to.eql('warning');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
@@ -19,9 +19,14 @@ describe('iD.validations.missing_tag', function () {
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationMissingTag(context);
|
||||
var validator = iD.validationMissingTag();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
it('has no errors on init', function() {
|
||||
@@ -34,7 +39,7 @@ describe('iD.validations.missing_tag', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.missing_tag);
|
||||
expect(issue.type).to.eql('missing_tag');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
|
||||
@@ -26,11 +26,17 @@ describe('iD.validations.tag_suggests_area', function () {
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationTagSuggestsArea(context);
|
||||
var validator = iD.validationTagSuggestsArea();
|
||||
var changes = context.history().changes();
|
||||
return validator(changes, context.graph());
|
||||
var entities = changes.modified.concat(changes.created);
|
||||
var issues = [];
|
||||
entities.forEach(function(entity) {
|
||||
issues = issues.concat(validator(entity, context));
|
||||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
|
||||
it('has no errors on init', function() {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
@@ -53,8 +59,8 @@ describe('iD.validations.tag_suggests_area', function () {
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.tag_suggests_area);
|
||||
expect(issue.severity).to.eql(iD.ValidationIssueSeverity.warning);
|
||||
expect(issue.type).to.eql('tag_suggests_area');
|
||||
expect(issue.severity).to.eql('warning');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe('iD.validations.coreValidator', function () {
|
||||
describe('iD.validations.validator', function () {
|
||||
var context;
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -34,7 +34,7 @@ describe('iD.validations.coreValidator', function () {
|
||||
issues = validator.getIssues();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql(iD.ValidationIssueType.missing_tag);
|
||||
expect(issue.type).to.eql('missing_tag');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
Reference in New Issue
Block a user