mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
Add code tests for more missing_tag cases
This commit is contained in:
@@ -5,11 +5,11 @@ describe('iD.validations.missing_tag', function () {
|
||||
context = iD.Context();
|
||||
});
|
||||
|
||||
function createInvalidWay() {
|
||||
function createWay(tags) {
|
||||
var n1 = iD.Node({id: 'n-1', loc: [4,4]});
|
||||
var n2 = iD.Node({id: 'n-2', loc: [4,5]});
|
||||
|
||||
var w = iD.Way({id: 'w-1', nodes: ['n-1', 'n-2']});
|
||||
var w = iD.Way({id: 'w-1', nodes: ['n-1', 'n-2'], tags: tags});
|
||||
|
||||
context.perform(
|
||||
iD.actionAddEntity(n1),
|
||||
@@ -18,6 +18,23 @@ describe('iD.validations.missing_tag', function () {
|
||||
);
|
||||
}
|
||||
|
||||
function createRelation(tags) {
|
||||
var n1 = iD.Node({id: 'n-1', loc: [4,4]});
|
||||
var n2 = iD.Node({id: 'n-2', loc: [4,5]});
|
||||
var n3 = iD.Node({id: 'n-3', loc: [5,5]});
|
||||
|
||||
var w = iD.Way({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3', 'n-1']});
|
||||
var r = iD.Relation({id: 'r-1', members: [{id: 'w-1'}], tags: tags});
|
||||
|
||||
context.perform(
|
||||
iD.actionAddEntity(n1),
|
||||
iD.actionAddEntity(n2),
|
||||
iD.actionAddEntity(n3),
|
||||
iD.actionAddEntity(w),
|
||||
iD.actionAddEntity(r)
|
||||
);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
var validator = iD.validationMissingTag();
|
||||
var changes = context.history().changes();
|
||||
@@ -34,8 +51,20 @@ describe('iD.validations.missing_tag', function () {
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('finds missing tags', function() {
|
||||
createInvalidWay();
|
||||
it('ignores way with descriptive tags', function() {
|
||||
createWay({ leisure: 'park' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores multipolygon with descriptive tags', function() {
|
||||
createRelation({ leisure: 'park', type: 'multipolygon' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('finds no tags', function() {
|
||||
createWay({});
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
@@ -44,5 +73,35 @@ describe('iD.validations.missing_tag', function () {
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
|
||||
it('finds no descriptive tags', function() {
|
||||
createWay({ name: 'Main Street', source: 'Bing' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql('missing_tag');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('w-1');
|
||||
});
|
||||
|
||||
it('finds no descriptive tags on multipolygon', function() {
|
||||
createRelation({ name: 'City Park', source: 'Bing', type: 'multipolygon' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql('missing_tag');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('r-1');
|
||||
});
|
||||
|
||||
it('finds no type tag on relation', function() {
|
||||
createRelation({ name: 'City Park', source: 'Bing', leisure: 'park' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(1);
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql('missing_tag');
|
||||
expect(issue.entities).to.have.lengthOf(1);
|
||||
expect(issue.entities[0].id).to.eql('r-1');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user