Skip to content

Commit

Permalink
Merge pull request #503 from LiskHQ/471-improve-test-coverage
Browse files Browse the repository at this point in the history
Improve test coverage - Closes #471
  • Loading branch information
yasharAyari authored Mar 2, 2018
2 parents 8a26af6 + 1402707 commit f92f0af
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
10 changes: 0 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ module.exports = function (config) {
functions: 80,
lines: 80,
excludes: [
'src/components/voting/voting.js',
'src/components/confirmVotes/index.js',
'src/components/confirmVotes/confirmVotes.js',
'src/components/delegateSidebar/index.js',
'src/components/setting/index.js',
'src/components/setting/setting.js',
Expand All @@ -70,14 +67,9 @@ module.exports = function (config) {
'src/store/middlewares/peers.js',
'src/store/middlewares/savedAccounts.js',
'src/store/middlewares/socket.js',
'src/components/account/account.js',
'src/components/account/address.js',
'src/components/account/index.js',
'src/components/account/index.js',
'src/components/accountVisual/demo.js',
'src/components/delegateList/votingHeader.js',
'src/components/app/index.js',
'src/components/dashboard/index.js',
'src/components/transactions/transactionList.js',
'src/components/relativeLink/index.js',
'src/components/receiveDialog/receiveDialog.js',
Expand All @@ -86,9 +78,7 @@ module.exports = function (config) {
'src/components/secondPassphrase/index.js',
'src/components/authenticate/index.js',
'src/components/authenticate/authenticate.js',
'src/components/menuBar/menuBar.js',
'src/components/multiStep/index.js',
'src/components/passphrase/info/index.js',
'src/components/passphrase/create/index.js',
'src/components/passphrase/safekeeping/index.js',
'src/components/toolbox/checkbox/index.js',
Expand Down
2 changes: 1 addition & 1 deletion src/components/confirmVotes/confirmVotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ConfirmVotes extends React.Component {
className={`${styles.backButton} back`}
onClick={() => prevStep({ reset: skipped })}>{t('Back')}</Button>
<Checkbox
className={styles.checkbox}
className={`${styles.checkbox} confirmSlider`}
label={t(`Confirm (Fee: ${fromRawLsk(fees.vote)} LSK)`)}
icons={{
done: 'checkmark',
Expand Down
31 changes: 29 additions & 2 deletions src/components/confirmVotes/confirmVotes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,40 @@ describe('ConfirmVotes', () => {
wrapper = mount(<ConfirmVotes {...props}></ConfirmVotes>);
});


it('should click to back button call prevStep', () => {
wrapper.find('button.back').simulate('click');
expect(props.prevStep).to.be.calledWith();
});

it('should click to confirm button call votePlaced', () => {
it('should click to confirm button call votePlaced with success equal to true', () => {
wrapper.find('button.confirm').simulate('click');
expect(props.nextStep).to.be.calledWith();
});

it('should drag slider checkbox call nextStep', () => {
const clock = sinon.useFakeTimers({
toFake: ['setTimeout', 'clearTimeout', 'Date'],
});
wrapper.find('.confirmSlider label').props().onMouseDown({ nativeEvent: { pageX: 870 } });
// When I start dragging the arrow
wrapper.find('.confirmSlider label').props().onMouseMove({ nativeEvent: { pageX: 870 } });

// And I keep dragging a bit more
wrapper.find('.confirmSlider label').props().onMouseMove({ nativeEvent: { pageX: 921 } });
// When I then 'drop' the arrow
wrapper.find('.confirmSlider label').props().onMouseLeave();
wrapper.update();
clock.tick(250);
wrapper.update();
expect(props.nextStep).to.be.calledWith();
clock.restore();
});

it('should click to confirm button call votePlaced with success equal to false', () => {
props.votePlaced = (data) => {
data.goToNextStep({ success: false });
};
wrapper.setProps(props);
wrapper.find('button.confirm').simulate('click');
expect(props.nextStep).to.be.calledWith();
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/passphrase/info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Info = ({ t, useCaseNote, securityNote, fee, nextStep, backButtonFn }) =>
<ActionBar
secondaryButton={{
label: t('Back'),
onClick: typeof backButtonFn === 'function' ? backButtonFn : () => {},
onClick: backButtonFn,
}}
primaryButton={{
label: t('Next'),
Expand Down

0 comments on commit f92f0af

Please sign in to comment.