Feat: zodern solution to stubvalue promise

This commit is contained in:
Gabriel Grubba
2023-11-29 16:09:01 -03:00
parent 4e47950e49
commit f2896786f7
3 changed files with 32 additions and 5 deletions

View File

@@ -893,11 +893,13 @@ export class Connection {
if (options.returnServerPromise) {
return future;
}
return options.returnStubValue
? future.then(() => stubReturnValue)
: {
stubValuePromise: future,
};
if (options.returnStubValue) {
return future.then(() => stubReturnValue);
}
future.stub = stubReturnValue;
return future;
}
return options.returnStubValue ? stubReturnValue : undefined;
}

View File

@@ -60,4 +60,5 @@ Package.onTest((api) => {
api.addFiles('test/livedata_tests.js');
api.addFiles('test/livedata_test_service.js');
api.addFiles('test/random_stream_tests.js');
api.addFiles('test/livedata_callAsync_tests.js');
});

View File

@@ -0,0 +1,24 @@
if (Meteor.isServer) {
Meteor.methods({
"server-only"() {
return "result";
},
});
}
Meteor.methods({
"client-only"() {
return "result";
},
});
Tinytest.addAsync(
"livedata stub - callAsync works like in 2.x",
async function (t) {
let result = await Meteor.callAsync("server-only");
t.equal(result, "result");
result = await Meteor.callAsync("client-only");
t.equal(result, "result");
}
);