/
pure.js
40 lines (36 loc) · 935 Bytes
/
pure.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';
/*jsl predef:define*/
/*jsl predef:it*/
var Validator = require('../lib/validator');
var should = require('chai').should();
describe('API', function () {
describe('arguments are pure', function () {
// Pure meaning they aren't modified by the function call
beforeEach(function () {
this.validator = new Validator();
});
it('"dependencies" constraint', function () {
var data = {
"foo": [1,2,3],
"bar": 2
};
var schema = {
"dependencies": {
"bar": {
"properties": {
"foo": {
"type": "array",
"items": {"type":"integer"}
},
"bar": {"type": "integer"}
},
"required": ["foo", "bar"]
}
}
};
Object.freeze(data.foo);
Object.freeze(data);
this.validator.validate(data, schema);
});
});
});