// Test that operations are executed in the right order
// We prevent Mocha from catching the exception we throw on purpose by remembering all current handlers, remove them and register them back after test ends
consttestRightOrder=asyncd=>{
constdocs=awaitd.findAsync({})
assert.equal(docs.length,0)
awaitd.insertAsync({a:1})
awaitd.updateAsync({a:1},{a:2},{})
constdocs2=awaitd.findAsync({})
assert.equal(docs2[0].a,2)
d.updateAsync({a:2},{a:3},{})// not awaiting
d.executor.pushAsync(async()=>{thrownewError('Some error')})// not awaiting
constdocs3=awaitd.findAsync({})
assert.equal(docs3[0].a,3)
}
// Note: The following test does not have any assertion because it
// is meant to address the deprecation warning:
// (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
// see
consttestEventLoopStarvation=asyncd=>{
consttimes=1001
leti=0
while(i<times){
i++
d.findAsync({bogus:'search'})
}
awaitd.findAsync({bogus:'search'})
}
// Test that operations are executed in the right order even with no callback