- fix test: 'mongo-livedata - specified _id MONGO | STRING'

This commit is contained in:
denihs
2023-02-15 14:54:06 -04:00
parent a263c16a7c
commit fb77ffd403
2 changed files with 16 additions and 15 deletions

View File

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

View File

@@ -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);
},
]);