Created
June 3, 2014 04:57
-
-
Save dburles/7853d478f36555301317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tinytest.add('Working', function(test) { | |
Books = new Meteor.Collection('books' + test.id); | |
Authors = new Meteor.Collection('authors' + test.id); | |
var author1 = Authors.insert({ | |
firstName: 'Charles', | |
lastName: 'Darwin' | |
}); | |
var book1 = Books.insert({ | |
authorId: author1, | |
name: 'On the Origin of Species', | |
rating: 1 | |
}); | |
// Set up hooks | |
Hooks.before.update(Books, '$set', 'name', function(userId, doc, fieldNames, modifier, options) { | |
modifier.$set.rating = 5; | |
}); | |
Books.update(book1, { | |
$set: { | |
name: 'Test', | |
'dotted.test': 'stuff' | |
} | |
}); | |
var book = Books.findOne(book1); | |
test.equal(book.rating, 5); | |
Books.update(book1, { | |
$set: { | |
dummy: true, | |
rating: 1 | |
} | |
}); | |
book = Books.findOne(book1); | |
test.equal(book.dummy, true); | |
test.equal(book.rating, 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment