Permalink
Browse files

add failing test for isRequired setting of path

  • Loading branch information...
aheckmann committed Mar 19, 2011
1 parent c62a06a commit 4c6e45a9de38945d49c04a13f198842ad82b69ce
Showing with 21 additions and 0 deletions.
  1. +21 −0 test/model.test.js
View
@@ -902,6 +902,8 @@ module.exports = {
var post = new TestCallingValidation;
+ post.schema.path('item').isRequired.should.be.true;
+
should.strictEqual(post.isNew, true);
post.validate(function(err){
@@ -919,6 +921,25 @@ module.exports = {
},
+ 'test setting required to false': function () {
+ function validator () {
+ return true;
+ }
+
+ mongoose.model('TestRequiredFalse', new Schema({
+ result: { type: String, validate: [validator, 'chump validator'], required: false }
+ }));
+
+ var db = start()
+ , TestV = db.model('TestRequiredFalse');
+
+ var post = new TestV;
+
+ post.schema.path('result').isRequired.should.be.false;
+
+ db.close();
+ },
+
'test defaults application': function(){
var now = Date.now();

0 comments on commit 4c6e45a

Please sign in to comment.