From fb77ffd403b0bb1642906163ade9d70567b4d932 Mon Sep 17 00:00:00 2001 From: denihs Date: Wed, 15 Feb 2023 14:54:06 -0400 Subject: [PATCH] - fix test: 'mongo-livedata - specified _id MONGO | STRING' --- .../ddp-client/common/livedata_connection.js | 2 +- packages/mongo/mongo_livedata_tests.js | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/ddp-client/common/livedata_connection.js b/packages/ddp-client/common/livedata_connection.js index cd2176a8ef..64a9b05602 100644 --- a/packages/ddp-client/common/livedata_connection.js +++ b/packages/ddp-client/common/livedata_connection.js @@ -864,7 +864,7 @@ export class Connection { // block waiting for the result. if (future) { return options.returnStubValue - ? stubReturnValue + ? future : { stubValuePromise: future, }; diff --git a/packages/mongo/mongo_livedata_tests.js b/packages/mongo/mongo_livedata_tests.js index 4459d56539..0fb3e0d109 100644 --- a/packages/mongo/mongo_livedata_tests.js +++ b/packages/mongo/mongo_livedata_tests.js @@ -2790,27 +2790,28 @@ Tinytest.add('mongo-livedata - rewrite selector', function(test) { }); testAsyncMulti('mongo-livedata - specified _id', [ - function (test, expect) { + function(test, expect) { this.collectionName = Random.id(); if (Meteor.isClient) { Meteor.call('createInsecureCollection', this.collectionName); Meteor.subscribe('c-' + this.collectionName, expect()); } - }, function (test, expect) { - var expectError = expect(function (err, result) { + }, + async function(test, expect) { + const expectError = expect(async function(err, result) { test.isTrue(err); - var doc = coll.findOne(); - test.equal(doc.name, "foo"); + + const doc = await coll.findOneAsync(); + test.equal(doc.name, 'foo'); }); - var coll = new Mongo.Collection(this.collectionName); - coll.insert({_id: "foo", name: "foo"}, expect(function (err1, id) { - test.equal(id, "foo"); - var doc = coll.findOne(); - test.equal(doc._id, "foo"); - Meteor._suppress_log(1); - coll.insert({_id: "foo", name: "bar"}, expectError); - })); - } + const coll = new Mongo.Collection(this.collectionName); + const id = await coll.insertAsync({ _id: 'foo', name: 'foo' }); + test.equal(id, 'foo'); + const doc = await coll.findOneAsync(); + test.equal(doc._id, 'foo'); + Meteor._suppress_log(1); + await coll.insertAsync({ _id: 'foo', name: 'bar' }).catch(expectError); + }, ]);