mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Feat: zodern solution to stubvalue promise
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
24
packages/ddp-client/test/livedata_callAsync_tests.js
Normal file
24
packages/ddp-client/test/livedata_callAsync_tests.js
Normal 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");
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user