Skip to content

Commit

Permalink
Add simple test to verify pure-ness of plain validate() call
Browse files Browse the repository at this point in the history
  • Loading branch information
awwright committed Feb 2, 2015
1 parent b7ba2e1 commit b61cc4a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/pure.js
@@ -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);
});
});
});

0 comments on commit b61cc4a

Please sign in to comment.