-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from jdgjsag67251/296-after-update-direct-find
#296: After update direct find
- Loading branch information
Showing
5 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Mongo } from 'meteor/mongo' | ||
import { Tinytest } from 'meteor/tinytest' | ||
|
||
Tinytest.addAsync('issue #296 - after update hook always finds all updated', function (test, next) { | ||
const collection = new Mongo.Collection(null) | ||
|
||
collection.before.find((userId, selector) => { | ||
selector.removedAt = { $exists: false } | ||
|
||
return true | ||
}) | ||
|
||
let beforeCalled = false | ||
collection.before.update(() => { | ||
beforeCalled = true | ||
}) | ||
|
||
let afterCalled = false | ||
collection.after.update(() => { | ||
afterCalled = true | ||
}) | ||
|
||
const id = collection.insert({ test: true }) | ||
|
||
collection.update(id, { $set: { removedAt: new Date() } }, () => { | ||
test.equal(beforeCalled, true) | ||
test.equal(afterCalled, true) | ||
next() | ||
}) | ||
}) | ||
|
||
Tinytest.addAsync('issue #296 - after insert hook always finds all inserted', function (test, next) { | ||
const collection = new Mongo.Collection(null) | ||
|
||
collection.before.find((userId, selector) => { | ||
selector.removedAt = { $exists: false } | ||
|
||
return true | ||
}) | ||
|
||
let beforeCalled = false | ||
collection.before.insert(() => { | ||
beforeCalled = true | ||
}) | ||
|
||
let afterCalled = false | ||
collection.after.insert(() => { | ||
afterCalled = true | ||
}) | ||
|
||
collection.insert({ removedAt: new Date() }, () => { | ||
test.equal(beforeCalled, true) | ||
test.equal(afterCalled, true) | ||
next() | ||
}) | ||
}) |
This file contains 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