Files
iD/test/spec/validations/validator.js
T
Bryan Housel 8b1c0551cc WIP: understand state held by the validator, avoid translations
- Make sure all state variables prefixed with `_`
- Add explicit `init`/`reset` methods
  (graph/entity refs should never persist through a save to OSM)
- Thinking of how best cache validation results
2019-04-05 09:28:36 -04:00

44 lines
1.3 KiB
JavaScript

describe('iD.validations.validator', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
});
function createInvalidWay() {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2']});
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(w)
);
}
it('has no issues on init', function() {
var validator = new iD.coreValidator(context);
validator.init();
var issues = validator.getIssues();
expect(issues).to.have.lengthOf(0);
});
it('populates issues on validate', function() {
createInvalidWay();
var validator = new iD.coreValidator(context);
validator.init();
var issues = validator.getIssues();
expect(issues).to.have.lengthOf(0);
validator.validate();
issues = validator.getIssues();
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');
});
});