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

Commit

Permalink
Fixed a wrong usage of arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
reyraa committed Nov 17, 2017
1 parent d37edf5 commit 9abf088
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/authenticate/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Authenticate extends React.Component {
<AuthInputs
passphrase={this.state.passphrase}
secondPassphrase={this.state.secondPassphrase}
onChange={handleChange.bind(this, this)} />
onChange={handleChange.bind(this)} />

<ActionBar
secondaryButton={{
Expand Down
4 changes: 2 additions & 2 deletions src/components/registerDelegate/registerDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class RegisterDelegate extends React.Component {
<Input label={this.props.t('Delegate name')} required={true}
autoFocus={true}
className='username'
onChange={handleChange.bind(this, this, 'name')}
onChange={handleChange.bind(this, 'name')}
error={this.state.name.error}
value={this.state.name.value} />
<AuthInputs
passphrase={this.state.passphrase}
secondPassphrase={this.state.secondPassphrase}
onChange={handleChange.bind(this, this)} />
onChange={handleChange.bind(this)} />
<hr/>
<InfoParagraph>
{this.props.t('Becoming a delegate requires registration. You may choose your own delegate name, which can be used to promote your delegate. Only the top 101 delegates are eligible to forge. All fees are shared equally between the top 101 delegates.')}
Expand Down
73 changes: 46 additions & 27 deletions src/components/secondPassphrase/secondPassphrase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,57 @@ describe('SecondPassphrase', () => {
i18n: PropTypes.object.isRequired,
},
};
const prop = {
account,
peers,
registerSecondPassphrase: spy(),
t: key => key,
};
const passphrase = 'wagon stock borrow episode laundry kitten salute link globe zero feed marble';

beforeEach(() => {
wrapper = mount(<SecondPassphrase {...prop} />, options);
});
describe('Authenticated', () => {
const prop = {
account,
passphrase,
peers,
registerSecondPassphrase: spy(),
t: key => key,
};

it('renders Passphrase component', () => {
expect(wrapper.find('Passphrase')).to.have.length(1);
});
beforeEach(() => {
wrapper = mount(<SecondPassphrase {...prop} />, options);
});

it('should mount SecondPassphrase with appropriate properties', () => {
const props = wrapper.find('Passphrase').props();
expect(props.securityNote).to.be.equal('Losing access to this passphrase will mean no funds can be sent from this account.');
expect(props.useCaseNote).to.be.equal('your second passphrase will be required for all transactions sent from this account');
expect(props.confirmButton).to.be.equal('Register');
expect(props.fee).to.be.equal(Fees.setSecondPassphrase);
expect(props.keepModal).to.be.equal(true);
expect(typeof props.onPassGenerated).to.be.equal('function');
it('renders Passphrase component', () => {
expect(wrapper.find('Passphrase')).to.have.length(1);
});

it('should mount SecondPassphrase with appropriate properties', () => {
const props = wrapper.find('Passphrase').props();
expect(props.securityNote).to.be.equal('Losing access to this passphrase will mean no funds can be sent from this account.');
expect(props.useCaseNote).to.be.equal('your second passphrase will be required for all transactions sent from this account');
expect(props.confirmButton).to.be.equal('Register');
expect(props.fee).to.be.equal(Fees.setSecondPassphrase);
expect(props.keepModal).to.be.equal(true);
expect(typeof props.onPassGenerated).to.be.equal('function');
});

it('should call registerSecondPassphrase if props.onPassGenerated is called', () => {
const props = wrapper.find('Passphrase').props();
props.onPassGenerated('sample passphrase');
expect(prop.registerSecondPassphrase).to.have.been.calledWith({
activePeer: peers.data,
secondPassphrase: 'sample passphrase',
account,
});
});
});

it('should call registerSecondPassphrase if props.onPassGenerated is called', () => {
const props = wrapper.find('Passphrase').props();
props.onPassGenerated('sample passphrase');
expect(prop.registerSecondPassphrase).to.have.been.calledWith({
activePeer: peers.data,
secondPassphrase: 'sample passphrase',
account,
describe('Not authenticated', () => {
it('Should mount an Authenticate component is no passphrase provided', () => {
const prop = {
account,
peers,
registerSecondPassphrase: spy(),
t: key => key,
};

wrapper = mount(<SecondPassphrase {...prop} />, options);
expect(wrapper.find('Authenticate')).to.have.length(1);
});
});
});
4 changes: 2 additions & 2 deletions src/utils/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const authStateIsValid = state => (
state.secondPassphrase.value !== ''
);

export const handleChange = (component, name, value, error) => {
component.setState({
export const handleChange = function (name, value, error) {
this.setState({
[name]: {
value,
error: typeof error === 'string' ? error : undefined,
Expand Down

0 comments on commit 9abf088

Please sign in to comment.