From 7ee09ec7159cd113e400bb4c2fe3ca61a3e531b6 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Fri, 12 Oct 2018 15:48:10 +0200 Subject: [PATCH 1/2] :bug: Fix list of votes in wallet page --- src/actions/account.js | 4 ++-- src/components/transactions/walletTransactions/index.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/actions/account.js b/src/actions/account.js index ce2e96c20f..06018d96a4 100644 --- a/src/actions/account.js +++ b/src/actions/account.js @@ -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, getAlllVotes, getVoters } from '../utils/api/delegate'; import { loadTransactionsFinish, transactionsUpdated } from './transactions'; import { delegateRegisteredFailure } from './delegate'; import { errorAlertDialogDisplayed } from './dialog'; @@ -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 getAlllVotes(activePeer, address).then(({ data }) => { dispatch({ type: actionTypes.accountAddVotes, votes: data.votes, diff --git a/src/components/transactions/walletTransactions/index.test.js b/src/components/transactions/walletTransactions/index.test.js index 6112b02769..3bdf39996d 100644 --- a/src/components/transactions/walletTransactions/index.test.js +++ b/src/components/transactions/walletTransactions/index.test.js @@ -45,7 +45,7 @@ describe('WalletTransactions Component', () => { beforeEach(() => { transactionsActionsStub = stub(transactionsAPI, 'getTransactions'); - delegateVotesStub = stub(delegateAPI, 'getVotes'); + delegateVotesStub = stub(delegateAPI, 'getAlllVotes'); delegateVotersStub = stub(delegateAPI, 'getVoters'); delegateVotesStub.returnsPromise().resolves({ data: { votes: [accounts['delegate candidate']] } }); From b5bbb90a01c930ed335db38788243d4ebd4d2826 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Fri, 12 Oct 2018 15:50:37 +0200 Subject: [PATCH 2/2] :recycle: Fix typo: getAlllVotes -> getAllVotes --- src/actions/account.js | 4 ++-- src/actions/search.js | 4 ++-- .../transactions/walletTransactions/index.test.js | 2 +- src/utils/api/delegate.js | 2 +- src/utils/api/delegate.test.js | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/actions/account.js b/src/actions/account.js index 06018d96a4..0aa005739d 100644 --- a/src/actions/account.js +++ b/src/actions/account.js @@ -1,7 +1,7 @@ import i18next from 'i18next'; import actionTypes from '../constants/actions'; import { setSecondPassphrase, getAccount } from '../utils/api/account'; -import { registerDelegate, getDelegate, getAlllVotes, 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'; @@ -70,7 +70,7 @@ export const passphraseUsed = data => ({ export const accountVotesFetched = ({ address }) => (dispatch, getState) => { const activePeer = getState().peers.data; - return getAlllVotes(activePeer, address).then(({ data }) => { + return getAllVotes(activePeer, address).then(({ data }) => { dispatch({ type: actionTypes.accountAddVotes, votes: data.votes, diff --git a/src/actions/search.js b/src/actions/search.js index 4e4eecaa4e..fe94a34bbc 100644 --- a/src/actions/search.js +++ b/src/actions/search.js @@ -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 }) => @@ -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: { diff --git a/src/components/transactions/walletTransactions/index.test.js b/src/components/transactions/walletTransactions/index.test.js index 3bdf39996d..27a5548a9b 100644 --- a/src/components/transactions/walletTransactions/index.test.js +++ b/src/components/transactions/walletTransactions/index.test.js @@ -45,7 +45,7 @@ describe('WalletTransactions Component', () => { beforeEach(() => { transactionsActionsStub = stub(transactionsAPI, 'getTransactions'); - delegateVotesStub = stub(delegateAPI, 'getAlllVotes'); + delegateVotesStub = stub(delegateAPI, 'getAllVotes'); delegateVotersStub = stub(delegateAPI, 'getVoters'); delegateVotesStub.returnsPromise().resolves({ data: { votes: [accounts['delegate candidate']] } }); diff --git a/src/utils/api/delegate.js b/src/utils/api/delegate.js index 7506f63980..3be4c875cf 100644 --- a/src/utils/api/delegate.js +++ b/src/utils/api/delegate.js @@ -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) { diff --git a/src/utils/api/delegate.test.js b/src/utils/api/delegate.test.js index 120c6a8d7c..0aa10a1268 100644 --- a/src/utils/api/delegate.test.js +++ b/src/utils/api/delegate.test.js @@ -8,7 +8,7 @@ import { vote, getVotes, getVoters, - getAlllVotes, + getAllVotes, registerDelegate } from './delegate'; import accounts from '../../../test/constants/accounts'; @@ -143,14 +143,14 @@ 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]); }); @@ -158,7 +158,7 @@ describe('Utils: Delegate', () => { 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]); }); });