Remove Promise chain, fix formatting test subscription (#1218)

This commit is contained in:
Jaco Greeff
2019-07-28 00:20:43 +02:00
committed by GitHub
parent 4094b44625
commit c31bd20c6a
2 changed files with 6 additions and 7 deletions
+3 -1
View File
@@ -42,7 +42,7 @@ function formattingTests (version: string, storage: Storage, encodedValues: [str
: null
)
),
subscribe: jest.fn((type, method, params, cb): void => {
subscribe: jest.fn((type, method, params, cb): Promise<void> => {
if (params[0][0] === CONTRACT_KEY) {
// this emulates https://github.com/polkadot-js/api/issues/1051
cb(null, {
@@ -69,6 +69,8 @@ function formattingTests (version: string, storage: Storage, encodedValues: [str
]
});
}
return Promise.resolve();
})
};
+3 -6
View File
@@ -198,12 +198,9 @@ export default class Rpc implements RpcInterface {
observer.next(this.formatOutput(method, params, result));
};
// FIXME This is a work-around, provider.subscribe _should_ always return,
// however in some cases `this.provider.subscribe.catch` yields ".catch of
// undefined", so here we flatten via Promise.reolve (which doe sfollow)
subscriptionPromise = Promise.resolve(
this.provider.subscribe(subType, subName, paramsJson, update)
).catch(errorHandler);
subscriptionPromise = this.provider
.subscribe(subType, subName, paramsJson, update)
.catch(errorHandler);
} catch (error) {
errorHandler(error);
}