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

Register as delegate - Closes #354 #543

Merged
merged 13 commits into from
Aug 11, 2017
Merged

Conversation

reyraa
Copy link
Contributor

@reyraa reyraa commented Aug 1, 2017

Closes #354

@@ -20,7 +21,13 @@ const HeaderElement = props => (
theme={styles}
>
<MenuItem caption="Register second passphrase" />
<MenuItem caption="Register as delegate" />
<MenuItem caption="Register as delegate"
className={(props.account.isDelegate) ? styles.hidden : ''}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the PR is in progress, but I just noticed this one thing. IMO more elegant way to conditionally hide an element in react is the ternary operator - {shouldShow ? <Element /> : null }.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a small component with no reprinting effect, there's no difference. I'll change anyways.

slaweet
slaweet previously requested changes Aug 2, 2017
@@ -98,8 +98,10 @@ class LoginFormComponent extends React.Component {
getAccount(this.props.peers.data, accountInfo.address).then((result) => {
onAccountUpdated(result);
getDelegate(this.props.peers.data, accountInfo.publicKey).then((data) => {
console.log('success');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this console.log

onAccountUpdated({ delegate: data.delegate, isDelegate: true });
}).catch(() => {
console.log('error');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this console.log

className='second-secret'
value={this.state.secondSecret} />
}
<hr/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hr is not visible due to display:none from passphrase.css. passphrase.css needs to be fixed.

});

const mapDispatchToProps = dispatch => ({
onAccountUpdated: data => dispatch(accountUpdated(data)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot find where is this used.

@@ -20,3 +20,6 @@
.menu {
right: -16px !important;
}
.hidden {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.hidden is not used.

it('should return a dispatch object', () => {
const props = mountedAccount.find(RegisterDelegate).props();
const data = props.showSuccessAlert('sample text');
expect(data).to.be.equal();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

it('should return a dispatch object', () => {
const props = mountedAccount.find(RegisterDelegate).props();
const data = props.showErrorAlert('sample text');
expect(data).to.be.equal();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

wrapper = mount(<RegisterDelegate {...normalProps} />);
});

it('renders an InfoParagraph components', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "components" -> "component"

},
closeDialog: () => {},
onAccountUpdated: () => {},
showSuccessAlert: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this showSuccessAlert: sinon.spy() and then expect that it has been called when necessary.

Those tests ending with wrapper.find('.submit-button').simulate('click'); and not checking anything with expect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that I'm not doing this either (in send.test.js). I tried to but the spy does not seem to be called.

closeDialog: () => {},
onAccountUpdated: () => {},
showSuccessAlert: () => {},
showErrorAlert: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

});

it('does not allow registering an existing username', () => {
delegateApiMock.expects('registerDelegate').resolves({ success: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be rejects not resolves

});

it('does not allow register as delegate for a delegate account', () => {
delegateApiMock.expects('registerDelegate').resolves({ success: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be rejects not resolves


wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } });
wrapper.find('.submit-button').simulate('click');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case for 'Username already exists' missing

},
closeDialog: () => {},
onAccountUpdated: () => {},
showSuccessAlert: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that I'm not doing this either (in send.test.js). I tried to but the spy does not seem to be called.

this.props.account.secondSecret &&
<Input label='Second secret' required={true}
className='second-secret'
value={this.state.secondSecret} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Input won't set this.state.secondSecret without onChange

@slaweet
Copy link
Contributor

slaweet commented Aug 4, 2017

Now that pending transactions PR is merged this should also dispatch a pending transaction (see how it's used in send send https://github.com/LiskHQ/lisk-nano/blob/development/src/components/send/send.js#L74-L81 )

@reyraa reyraa force-pushed the 354-register-as-delegate branch from d82b187 to 55ac449 Compare August 11, 2017 12:01
@reyraa reyraa requested a review from yasharAyari August 11, 2017 12:03
Copy link
Contributor

@yasharAyari yasharAyari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

@reyraa reyraa dismissed slaweet’s stale review August 11, 2017 12:43

Since Vit is not here and I've done the change requests I could handle

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants