mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
- fix test: 'upsert with an undefined selector, MONGO | STRING'
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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, [
|
||||
|
||||
Reference in New Issue
Block a user