Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple test to verify pure-ness of plain validate() call
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}); | ||
}); | ||
}); |