- fix test: 'mongo-livedata - document with length, MONGO | STRING'

This commit is contained in:
denihs
2023-02-14 11:16:39 -04:00
parent 16a4b91f27
commit ea2c579f94
3 changed files with 33 additions and 27 deletions

View File

@@ -864,7 +864,7 @@ export class Connection {
// block waiting for the result.
if (future) {
return options.returnStubValue
? future
? stubReturnValue
: {
stubValuePromise: future,
};

View File

@@ -783,11 +783,6 @@ Object.assign(Mongo.Collection.prototype, {
return result;
};
// const wrappedCallback = wrapCallback(
// callback,
// chooseReturnValueFromCollectionResult
// );
if (this._isRemoteCollection()) {
const result = await this._callMutatorMethodAsync('insertAsync', [doc]);

View File

@@ -1652,33 +1652,44 @@ _.each( ['STRING', 'MONGO'], function(idGeneration) {
// See https://github.com/meteor/meteor/issues/594.
testAsyncMulti('mongo-livedata - document with length, ' + idGeneration, [
function (test, expect) {
function(test, expect) {
this.collectionName = Random.id();
if (Meteor.isClient) {
Meteor.call('createInsecureCollection', this.collectionName, collectionOptions);
Meteor.call(
'createInsecureCollection',
this.collectionName,
collectionOptions
);
Meteor.subscribe('c-' + this.collectionName, expect());
}
}, function (test, expect) {
var self = this;
var coll = self.coll = new Mongo.Collection(self.collectionName, collectionOptions);
coll.insert({foo: 'x', length: 0}, expect(function (err, id) {
test.isFalse(err);
test.isTrue(id);
self.docId = id;
test.equal(coll.findOne(self.docId),
{_id: self.docId, foo: 'x', length: 0});
}));
},
function (test, expect) {
async function(test, expect) {
var self = this;
var coll = self.coll;
coll.update(self.docId, {$set: {length: 5}}, expect(function (err) {
test.isFalse(err);
test.equal(coll.findOne(self.docId),
{_id: self.docId, foo: 'x', length: 5});
}));
}
var coll = (self.coll = new Mongo.Collection(
self.collectionName,
collectionOptions
));
const id = await coll.insertAsync({ foo: 'x', length: 0 });
test.isTrue(id);
self.docId = id;
test.equal(await coll.findOneAsync(self.docId), {
_id: self.docId,
foo: 'x',
length: 0,
});
},
async function(test, expect) {
const self = this;
const coll = self.coll;
await coll.updateAsync(self.docId, { $set: { length: 5 } });
test.equal(await coll.findOneAsync(self.docId), {
_id: self.docId,
foo: 'x',
length: 5,
});
},
]);
testAsyncMulti('mongo-livedata - document with a date, ' + idGeneration, [