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

Commit

Permalink
Unskip some broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gina Contrino committed Nov 1, 2017
1 parent 79d0f40 commit 7330b38
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"electron-builder": "19.32.2",
"electron-json-storage": "^3.2.0",
"enzyme": "2.9.1",
"enzyme-adapter-react-15": "1.0.3",
"eslint": "4.8.0",
"eslint-config-airbnb": "15.1.0",
"eslint-config-google": "0.9.1",
Expand Down
11 changes: 9 additions & 2 deletions src/actions/forging.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 => ({
Expand All @@ -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 }));
});
};
17 changes: 9 additions & 8 deletions src/actions/forging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});
});
10 changes: 4 additions & 6 deletions src/components/decryptMessage/decryptMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('DecryptMessage', () => {
const props = {
account,
successToast: successToastSpy,
errorToast: sinon.spy(),
errorToast: errorSpy,
copyToClipboard: copyMock,
t: key => key,
};
Expand All @@ -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 } });
Expand Down

0 comments on commit 7330b38

Please sign in to comment.