diff --git a/src/actions/forging.js b/src/actions/forging.js
index 651912ef1..9e5ffa0c7 100644
--- a/src/actions/forging.js
+++ b/src/actions/forging.js
@@ -1,5 +1,6 @@
import actionTypes from '../constants/actions';
import { getForgedBlocks, getForgedStats } from '../utils/api/forging';
+import { errorAlertDialogDisplayed } from './dialog';
export const forgedBlocksUpdated = data => ({
data,
@@ -11,7 +12,10 @@ export const fetchAndUpdateForgedBlocks = ({ activePeer, limit, offset, generato
getForgedBlocks(activePeer, limit, offset, generatorPublicKey)
.then(response =>
dispatch(forgedBlocksUpdated(response.blocks)),
- );
+ )
+ .catch((error) => {
+ dispatch(errorAlertDialogDisplayed({ text: error.message }));
+ });
};
export const forgingStatsUpdated = data => ({
@@ -24,5 +28,8 @@ export const fetchAndUpdateForgedStats = ({ activePeer, key, startMoment, genera
getForgedStats(activePeer, startMoment, generatorPublicKey)
.then(response =>
dispatch(forgingStatsUpdated({ [key]: response.forged })),
- );
+ )
+ .catch((error) => {
+ dispatch(errorAlertDialogDisplayed({ text: error.message }));
+ });
};
diff --git a/src/actions/forging.test.js b/src/actions/forging.test.js
index 5920defc6..3f7e94d43 100644
--- a/src/actions/forging.test.js
+++ b/src/actions/forging.test.js
@@ -4,6 +4,7 @@ import actionTypes from '../constants/actions';
import { forgedBlocksUpdated, forgingStatsUpdated,
fetchAndUpdateForgedBlocks, fetchAndUpdateForgedStats } from './forging';
import * as forgingApi from '../utils/api/forging';
+import { errorAlertDialogDisplayed } from './dialog';
describe('actions', () => {
describe('forgedBlocksUpdated', () => {
@@ -64,12 +65,12 @@ describe('actions', () => {
expect(dispatch).to.have.been.calledWith(forgedBlocksUpdated('value'));
});
- it.skip('should dispatch errorAlertDialogDisplayed action if caught', () => {
+ it('should dispatch errorAlertDialogDisplayed action if caught', () => {
forgingApiMock.returnsPromise().rejects({ message: 'sample message' });
- // actionFunction(dispatch);
- // const expectedAction = errorAlertDialogDisplayed({ text: 'sample message' });
- // expect(dispatch).to.have.been.calledWith(expectedAction);
+ actionFunction(dispatch);
+ const expectedAction = errorAlertDialogDisplayed({ text: 'sample message' });
+ expect(dispatch).to.have.been.calledWith(expectedAction);
});
});
@@ -105,12 +106,12 @@ describe('actions', () => {
expect(dispatch).to.have.been.calledWith(forgingStatsUpdated({ [key]: 'value' }));
});
- it.skip('should dispatch errorAlertDialogDisplayed action if caught', () => {
+ it('should dispatch errorAlertDialogDisplayed action if caught', () => {
forgingApiMock.returnsPromise().rejects({ message: 'sample message' });
- // actionFunction(dispatch);
- // const expectedAction = errorAlertDialogDisplayed({ text: 'sample message' });
- // expect(dispatch).to.have.been.calledWith(expectedAction);
+ actionFunction(dispatch);
+ const expectedAction = errorAlertDialogDisplayed({ text: 'sample message' });
+ expect(dispatch).to.have.been.calledWith(expectedAction);
});
});
});
diff --git a/src/actions/savedAccounts.js b/src/actions/savedAccounts.js
index 135a39804..2c9ba928b 100644
--- a/src/actions/savedAccounts.js
+++ b/src/actions/savedAccounts.js
@@ -15,10 +15,6 @@ export const accountSaved = (data) => {
/**
* An action to dispatch accountRemoved
- *
- * @todo Currently the utility removed the entire array from localStorage.
- * it should remove only one item
- *
*/
export const accountRemoved = (publicKey) => {
removeSavedAccount(publicKey);
diff --git a/src/components/decryptMessage/decryptMessage.test.js b/src/components/decryptMessage/decryptMessage.test.js
index 121c1844e..7c2d9e68d 100644
--- a/src/components/decryptMessage/decryptMessage.test.js
+++ b/src/components/decryptMessage/decryptMessage.test.js
@@ -35,7 +35,7 @@ describe('DecryptMessage', () => {
const props = {
account,
successToast: successToastSpy,
- errorToast: sinon.spy(),
+ errorToast: errorSpy,
copyToClipboard: copyMock,
t: key => key,
};
@@ -51,20 +51,18 @@ describe('DecryptMessage', () => {
decryptMessageMock.restore();
});
- // ToDo find the problem with this test
- it.skip('shows error toast when couldn\'t decrypt a message', () => {
- decryptMessageMock.returnsPromise().rejects({ message: 'couldn\'t decrypt the message' });
+ it('shows error toast when couldn\'t decrypt a message', () => {
+ decryptMessageMock.throws({ message: 'couldn\'t decrypt the message' });
wrapper.find('.message textarea').simulate('change', { target: { value: message } });
wrapper.find('.senderPublicKey input').simulate('change', { target: { value: senderPublicKey } });
wrapper.find('.nonce input').simulate('change', { target: { value: nonce } });
wrapper.find('form').simulate('submit');
- expect(errorSpy).to.have.been.calledOnce();
expect(errorSpy).to.have.been.calledWith({ label: 'couldn\'t decrypt the message' });
});
it('allows to decrypt a message, copies encrypted message result to clipboard and shows success toast', () => {
copyMock.returns(true);
- decryptMessageMock.returnsPromise().resolves(decryptedMessage);
+ decryptMessageMock.returns(decryptedMessage);
wrapper.find('.message textarea').simulate('change', { target: { value: message } });
wrapper.find('.senderPublicKey input').simulate('change', { target: { value: senderPublicKey } });
wrapper.find('.nonce input').simulate('change', { target: { value: nonce } });
diff --git a/src/components/pricedButton/index.test.js b/src/components/pricedButton/index.test.js
index 1f2d188b4..46eea1cb4 100644
--- a/src/components/pricedButton/index.test.js
+++ b/src/components/pricedButton/index.test.js
@@ -13,7 +13,7 @@ describe('PricedButton', () => {
const props = {
fee: 5e8,
onClick: sinon.spy(),
- t: key => i18n.t(key),
+ t: (key, options) => i18n.t(key, options),
};
const insufficientBalance = 4.9999e8;
const sufficientBalance = 6e8;
@@ -29,8 +29,7 @@ describe('PricedButton', () => {
});
it('renders a span saying "Fee: 5 LSK"', () => {
- // TODO the text should actually contain 5 but in tests it doesn't
- expect(wrapper.find(`.${styles.fee}`).text()).to.be.equal(i18n.t('Fee: LSK'));
+ expect(wrapper.find(`.${styles.fee}`).text()).to.be.equal(i18n.t('Fee: 5 LSK'));
});
it('allows to click on Button', () => {
@@ -45,8 +44,7 @@ describe('PricedButton', () => {
});
it('renders a span saying "Insufficient funds for 5 LSK fee"', () => {
- // TODO the text should actually contain 5 but in tests it doesn't
- expect(wrapper.find(`.${styles.fee}`).text()).to.be.equal('Insufficient funds for LSK fee');
+ expect(wrapper.find(`.${styles.fee}`).text()).to.be.equal('Insufficient funds for 5 LSK fee');
});
it('sets the disabled attribute of the button', () => {
diff --git a/src/components/signMessage/signMessage.js b/src/components/signMessage/signMessage.js
index d8a607f44..579e688de 100644
--- a/src/components/signMessage/signMessage.js
+++ b/src/components/signMessage/signMessage.js
@@ -61,7 +61,7 @@ class SignMessageComponent extends React.Component {
{this.props.t('Note: Digital Signatures and signed messages are not encrypted!')}
-