Skip to content
Browse files

add test; isNew on subdocs is now false after save

  • Loading branch information...
1 parent 6ec79fd commit 48ff3d7d16e55d37dd77837df89e9971b1c6cd7f @aheckmann aheckmann committed
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/model.test.js
View
16 test/model.test.js
@@ -494,6 +494,22 @@ module.exports = {
db.close();
},
+ 'test isNew on embedded documents after saving': function(){
+ var db = start()
+ , BlogPost = db.model('BlogPost', collection);
+
+ var post = new BlogPost({ title: 'hocus pocus' })
+ post.comments.push({ title: 'Humpty Dumpty', comments: [{title: 'nested'}] });
+ post.get('comments')[0].isNew.should.be.true;
+ post.get('comments')[0].comments[0].isNew.should.be.true;
+ post.save(function (err) {
+ db.close();
+ should.strictEqual(null, err);
+ post.get('comments')[0].isNew.should.be.false;
+ post.get('comments')[0].comments[0].isNew.should.be.false;
+ });
+ },
+
'test isModified when modifying keys': function(){
var db = start()
, BlogPost = db.model('BlogPost', collection);

0 comments on commit 48ff3d7

Please sign in to comment.
Something went wrong with that request. Please try again.