Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
axelchalon committed Jan 21, 2019
1 parent ceb6169 commit 7a40419
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/light.js/src/rpc/other/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function getTransactionReceipt (transactionHash: string, api: any) {
* @return - The status of the transaction: (estimated), signed, sent, confirmed
*/
export function post$ (tx: Tx, options: PostOptions) {
const { estimate, passphrase, provider } = options;
if (!passphrase) {
if (!options || !options.passphrase) {
throw new Error('The passphrase is missing from the options');
}

const { estimate, passphrase, provider } = options;
const api = provider ? createApiFromProvider(provider) : getApi();

const source$ = Observable.create(async (observer: Observer<TxStatus>) => {
Expand Down
8 changes: 5 additions & 3 deletions packages/light.js/src/rpc/rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ const testRpc = (name: string, rpc$: RpcObservable<any, any>) =>
setApi(resolveApi());
});

const options = name === 'post$' ? { passphrase: 'passphrase' } : {};

it('should be a function', () => {
expect(typeof rpc$).toBe('function');
});

it('should return an Observable', () => {
expect(isObservable(rpc$({}))).toBe(true);
expect(isObservable(rpc$({}, options))).toBe(true);
});

it('result Observable should be subscribable', () => {
expect(() => rpc$({}).subscribe()).not.toThrow();
expect(() => rpc$({}, options).subscribe()).not.toThrow();
});

it('result Observable should return values', done => {
rpc$({}).subscribe(data => {
rpc$({}, options).subscribe(data => {
expect(data).not.toBeNull();
done();
});
Expand Down

0 comments on commit 7a40419

Please sign in to comment.