From edc899df72fdc55e35e8de8eecc7333bf93921e5 Mon Sep 17 00:00:00 2001 From: denihs Date: Mon, 13 Feb 2023 14:33:39 -0400 Subject: [PATCH] - fix test: 'recursive observe throws, MONGO | STRING' --- packages/mongo/mongo_livedata_tests.js | 48 +++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/packages/mongo/mongo_livedata_tests.js b/packages/mongo/mongo_livedata_tests.js index 01524e0ebb..d458565588 100644 --- a/packages/mongo/mongo_livedata_tests.js +++ b/packages/mongo/mongo_livedata_tests.js @@ -768,30 +768,36 @@ _.each( ['STRING', 'MONGO'], function(idGeneration) { // This behavior isn't great, but it beats deadlock. if (Meteor.isServer) { - Tinytest.addAsync("mongo-livedata - recursive observe throws, " + idGeneration, function (test, onComplete) { - var run = test.runId(); - var coll = new Mongo.Collection("observeInCallback-"+run, collectionOptions); + Tinytest.addAsync( + 'mongo-livedata - recursive observe throws, ' + idGeneration, + async function(test, onComplete) { + var run = test.runId(); + var coll = new Mongo.Collection( + 'observeInCallback-' + run, + collectionOptions + ); - var callbackCalled = false; - var handle = coll.find({}).observe({ - added: function (newDoc) { - callbackCalled = true; - test.throws(function () { - coll.find({}).observe(); - }); - } - }); - test.isFalse(callbackCalled); - // Insert a document. Observe that the added callback is called. - runInFence(function () { - coll.insert({foo: 42}); - }); - test.isTrue(callbackCalled); + var callbackCalled = false; + var handle = await coll.find({}).observe({ + added: async function(newDoc) { + callbackCalled = true; + await test.throwsAsync(async function() { + await coll.find({}).observe(); + }); + }, + }); + test.isFalse(callbackCalled); + // Insert a document. Observe that the added callback is called. + await runInFence(async function() { + await coll.insertAsync({ foo: 42 }); + }); + test.isTrue(callbackCalled); - handle.stop(); + handle.stop(); - onComplete(); - }); + onComplete(); + } + ); Tinytest.addAsync("mongo-livedata - cursor dedup, " + idGeneration, function (test, onComplete) { var run = test.runId();