mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Fix tests and lint warnings
This commit is contained in:
+3
-3
@@ -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' }
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+12
-7
@@ -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');
|
||||
});
|
||||
|
||||
+10
-5
@@ -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