smalley
Version:
Validates data passed in against a validation definition config.
35 lines (29 loc) • 1.11 kB
JavaScript
/* global describe */
/* global it */
;
var should = require('should');
var appRoot = require('app-root-path');
describe('#Get Validation Definition Tests', function() {
it('Should get valid json files and add it to validationDefinitions object', function(done) {
var getValDefs = require(appRoot + '/lib/getValDefs');
var expected = {
"phone" : { "type" : "[object String]", "require" : true},
"firstName" : { "type" : "[object String]", "require" : true},
"lastName" : {"type" : "[object String]", "require" : true},
"address" : {"type" : "[object Object]", "require" : false},
"city" : {"type" : "[object String]", "require" : false}
};
getValDefs('/test/customerDefs', function(err, defs) {
should.not.exist(err);
should.deepEqual(defs, expected);
done();
});
});
it('Should err with a filepath that has no defs', function(done) {
var getValDefs = require(appRoot + '/lib/getValDefs');
getValDefs('test/', function(err, defs) {
should.exist(err);
done();
});
});
});