Skip to content

Commit

Permalink
add failing test for isRequired setting of path
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Mar 19, 2011
1 parent c62a06a commit 4c6e45a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/model.test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ module.exports = {


var post = new TestCallingValidation; var post = new TestCallingValidation;


post.schema.path('item').isRequired.should.be.true;

should.strictEqual(post.isNew, true); should.strictEqual(post.isNew, true);


post.validate(function(err){ post.validate(function(err){
Expand All @@ -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(){ 'test defaults application': function(){
var now = Date.now(); var now = Date.now();


Expand Down

0 comments on commit 4c6e45a

Please sign in to comment.