- fix test: 'upsert with an undefined selector, MONGO | STRING'

This commit is contained in:
denihs
2023-02-14 10:56:06 -04:00
parent 92017df276
commit 16a4b91f27
2 changed files with 25 additions and 21 deletions

View File

@@ -863,9 +863,11 @@ export class Connection {
// If we're using the default callback on the server,
// block waiting for the result.
if (future) {
return {
stubValuePromise: future,
};
return options.returnStubValue
? future
: {
stubValuePromise: future,
};
}
return options.returnStubValue ? stubReturnValue : undefined;
}

View File

@@ -1626,27 +1626,29 @@ _.each( ['STRING', 'MONGO'], function(idGeneration) {
]);
// Regression test for https://github.com/meteor/meteor/issues/8666.
testAsyncMulti('mongo-livedata - upsert with an undefined selector, ' + idGeneration, [
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 coll = new Mongo.Collection(this.collectionName, collectionOptions);
var testWidget = {
name: 'Widget name'
};
coll.upsert(testWidget._id, testWidget, expect(function (error, insertDetails) {
test.isFalse(error);
testAsyncMulti(
'mongo-livedata - upsert with an undefined selector, ' + idGeneration,
[
function(test, expect) {
this.collectionName = Random.id();
if (Meteor.isClient) {
Meteor.call('createInsecureCollection', this.collectionName);
Meteor.subscribe('c-' + this.collectionName, expect());
}
},
async function(test, expect) {
const coll = new Mongo.Collection(this.collectionName, collectionOptions);
const testWidget = {
name: 'Widget name',
};
const insertDetails = await coll.upsertAsync(testWidget._id, testWidget, { returnStubValue: true });
test.equal(
coll.findOne(insertDetails.insertedId),
await coll.findOneAsync(insertDetails.insertedId),
Object.assign({ _id: insertDetails.insertedId }, testWidget)
);
}));
}
]);
},
]
);
// See https://github.com/meteor/meteor/issues/594.
testAsyncMulti('mongo-livedata - document with length, ' + idGeneration, [