-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
patternRequired.spec.js
40 lines (32 loc) · 1.14 KB
/
patternRequired.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var Ajv = require('ajv');
// var defFunc = require('../keywords/patternRequired');
var defineKeywords = require('..');
var should = require('chai').should();
describe.skip('keywords "patternRequired"', function() {
var ajvs = getAjvs();
var ajvsOP = getAjvs(true);
ajvs.forEach(function (ajv, i) {
it('should only validate against own properties when using patternRequired #' + i, function() {
var ajvOP = ajvsOP[i];
var schema = { patternRequired: [ 'f.*o' ] };
var baz = { foooo: false, fooooooo: 42.31 };
function FooThing() { this.bar = 123; }
FooThing.prototype = baz;
var object = new FooThing();
ajv.validate(schema, object).should.equal(true);
ajvOP.validate(schema, object).should.equal(false);
ajvOP.errors.should.have.length(1);
});
});
function getAjv(ownProperties) {
return new Ajv({ allErrors: true, ownProperties: ownProperties });
}
function getAjvs(ownProperties) {
return [
// defFunc(getAjv(ownProperties)),
// defineKeywords(getAjv(ownProperties), 'patternRequired'),
defineKeywords(getAjv(ownProperties))
];
}
});