Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
✅ Add tests for broadcastTransaction API method
Browse files Browse the repository at this point in the history
  • Loading branch information
willclarktech committed Jan 8, 2018
1 parent 1d82b75 commit e1442d2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/api/liskApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,43 @@ describe('Lisk API module', () => {
});
});

describe('#broadcastTransaction', () => {
let transaction;
let broadcastTransactionsResult;
let result;

beforeEach(() => {
transaction = {
key1: 'value1',
key2: 2,
};
broadcastTransactionsResult = { success: true };
sandbox
.stub(LSK, 'broadcastTransactions')
.returns(broadcastTransactionsResult);
result = LSK.broadcastTransaction(transaction);
return result;
});

it('should wrap the transaction in an array and call broadcastTransactions', () => {
return LSK.broadcastTransactions.should.be.calledWithExactly(
[transaction],
undefined,
);
});
it('should return the result of broadcasting the transaction', () => {
return result.should.equal(broadcastTransactionsResult);
});
it('should pass on the callback', () => {
LSK.broadcastTransactions.callsArgWith(1, broadcastTransactionsResult);
return new Promise(resolve => {
LSK.broadcastTransaction(transaction, resolve);
}).then(resultViaCallback =>
resultViaCallback.should.equal(broadcastTransactionsResult),
);
});
});

describe('#broadcastSignatures', () => {
let signatures;

Expand Down

0 comments on commit e1442d2

Please sign in to comment.