Skip to content

Commit 11f7ce6

Browse files
committed
added test to call validate with missing object.
1 parent 09b496f commit 11f7ce6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/object-basic-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// this test is run by Vows (as all files matching *test.js)
2+
3+
var vows = require('vows'),
4+
should = require('should');
5+
6+
var createSchema = require('..').createSchema,
7+
config = require('./config');
8+
9+
var schemaSimple = {
10+
type: 'string'
11+
};
12+
13+
vows.describe('Object Default').addBatch({
14+
'when calling without an object': {
15+
topic: function () {
16+
var schema = createSchema(schemaSimple);
17+
try {
18+
schema.validate(undefined);
19+
this.callback(null);
20+
} catch(err) {
21+
this.callback(err);
22+
}
23+
},
24+
'we get an error': function (err, result) {
25+
should.exist(err);
26+
err.should.have.property('message', 'JSON object is undefined');
27+
should.not.exist(result);
28+
}
29+
}
30+
}).export(module);

0 commit comments

Comments
 (0)