Skip to content

Commit

Permalink
Merge branch 'development' into 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Oct 12, 2018
2 parents a58dace + 3962948 commit 87cf8e5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/actions/account.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18next from 'i18next';
import actionTypes from '../constants/actions';
import { setSecondPassphrase, getAccount } from '../utils/api/account';
import { registerDelegate, getDelegate, getVotes, getVoters } from '../utils/api/delegate';
import { registerDelegate, getDelegate, getAllVotes, getVoters } from '../utils/api/delegate';
import { loadTransactionsFinish, transactionsUpdated } from './transactions';
import { delegateRegisteredFailure } from './delegate';
import { errorAlertDialogDisplayed } from './dialog';
Expand Down Expand Up @@ -70,7 +70,7 @@ export const passphraseUsed = data => ({
export const accountVotesFetched = ({ address }) =>
(dispatch, getState) => {
const activePeer = getState().peers.data;
return getVotes(activePeer, { address }).then(({ data }) => {
return getAllVotes(activePeer, address).then(({ data }) => {
dispatch({
type: actionTypes.accountAddVotes,
votes: data.votes,
Expand Down
4 changes: 2 additions & 2 deletions src/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import actionTypes from '../constants/actions';
import { loadingStarted, loadingFinished } from '../actions/loading';
import { getAccount } from '../utils/api/account';
import { getTransactions } from '../utils/api/transactions';
import { getDelegate, getVoters, getAlllVotes } from '../utils/api/delegate';
import { getDelegate, getVoters, getAllVotes } from '../utils/api/delegate';
import searchAll from '../utils/api/search';

const searchDelegate = ({ publicKey, address }) =>
Expand All @@ -22,7 +22,7 @@ const searchDelegate = ({ publicKey, address }) =>
const searchVotes = ({ address }) =>
(dispatch, getState) => {
const activePeer = getState().peers.data;
getAlllVotes(activePeer, address).then(response =>
getAllVotes(activePeer, address).then(response =>
dispatch({
type: actionTypes.searchVotes,
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('WalletTransactions Component', () => {

beforeEach(() => {
transactionsActionsStub = stub(transactionsAPI, 'getTransactions');
delegateVotesStub = stub(delegateAPI, 'getVotes');
delegateVotesStub = stub(delegateAPI, 'getAllVotes');
delegateVotersStub = stub(delegateAPI, 'getVoters');

delegateVotesStub.returnsPromise().resolves({ data: { votes: [accounts['delegate candidate']] } });
Expand Down
2 changes: 1 addition & 1 deletion src/utils/api/delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const vote = (
export const getVotes = (activePeer, { address, offset, limit }) =>
activePeer.votes.get({ address, limit, offset });

export const getAlllVotes = (activePeer, address) =>
export const getAllVotes = (activePeer, address) =>
new Promise((resolve, reject) => {
getVotes(activePeer, { address, offset: 0, limit: 100 }).then((votesEarlyBatch) => {
if (votesEarlyBatch.data.votes && votesEarlyBatch.data.votesUsed < 101) {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/api/delegate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
vote,
getVotes,
getVoters,
getAlllVotes,
getAllVotes,
registerDelegate } from './delegate';
import accounts from '../../../test/constants/accounts';

Expand Down Expand Up @@ -143,22 +143,22 @@ describe('Utils: Delegate', () => {
});
});

describe('getAlllVotes', () => {
describe('getAllVotes', () => {
it('should get all votes for an address with no parameters > 100', () => {
const address = '123L';
activePeerMockVotes.expects('get').withArgs({ address, offset: 0, limit: 100 })
.returnsPromise().resolves({ data: { votes: [1, 2, 3], votesUsed: 101 } });
activePeerMockVotes.expects('get').withArgs({ address, offset: 100, limit: 1 })
.returnsPromise().resolves({ data: { votes: [4], votesUsed: 101 } });
const returnedPromise = getAlllVotes(activePeer, address);
const returnedPromise = getAllVotes(activePeer, address);
expect(returnedPromise).to.eventually.equal([1, 2, 3, 4]);
});

it('should get all votes for an address with no parameters < 100', () => {
const address = '123L';
activePeerMockVotes.expects('get').withArgs({ address, offset: 0, limit: 100 })
.returnsPromise().resolves({ data: { votes: [1], votesUsed: 1 } });
const returnedPromise = getAlllVotes(activePeer, address);
const returnedPromise = getAllVotes(activePeer, address);
expect(returnedPromise).to.eventually.equal([1]);
});
});
Expand Down

0 comments on commit 87cf8e5

Please sign in to comment.