This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Create ActionBar React component - Closes #541 #563
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
362397f
Create ActionBar component
slaweet a9f329b
Use ActionBar in send and signMessageComponent
slaweet 8b22f0a
Add unit tests for actionBar
slaweet 01b7cac
Use ActionBar in passphrase component
slaweet e84184b
Remove inline styles from actionBar
slaweet 31d88d0
Fix import by name in actionBar
slaweet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import Button from 'react-toolbox/lib/button'; | ||
import grid from 'flexboxgrid/dist/flexboxgrid.css'; | ||
|
||
const ActionBar = props => ( | ||
<section style={{ margin: '0' }} | ||
className={`${grid.row} ${grid['between-xs']}`} > | ||
<Button label={props.secondaryButton.label || 'Cancel'} | ||
className={props.secondaryButton.className || 'cancel-button'} | ||
onClick={props.secondaryButton.onClick} /> | ||
<Button primary={true} raised={true} | ||
label={props.primaryButton.label} | ||
className={props.primaryButton.className || 'submit-button'} | ||
disabled={props.primaryButton.disabled} | ||
onClick={props.primaryButton.onClick}/> | ||
</section> | ||
); | ||
|
||
export default ActionBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import { mount } from 'enzyme'; | ||
import chaiEnzyme from 'chai-enzyme'; | ||
import sinon from 'sinon'; | ||
import sinonChai from 'sinon-chai'; | ||
import ActionBar from './'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the name of file |
||
import * as accountApi from '../../utils/api/account'; | ||
|
||
|
||
chai.use(sinonChai); | ||
chai.use(chaiEnzyme()); | ||
|
||
describe('ActionBar', () => { | ||
let wrapper; | ||
let props; | ||
|
||
beforeEach(() => { | ||
props = { | ||
secondaryButton: { | ||
label: 'Test cancel', | ||
onClick: sinon.spy(), | ||
}, | ||
primaryButton: { | ||
label: 'Test confirm', | ||
disabled: false, | ||
onClick: sinon.spy(), | ||
}, | ||
}; | ||
wrapper = mount(<ActionBar {...props} />); | ||
}); | ||
|
||
it('renders two Button components', () => { | ||
expect(wrapper.find('Button')).to.have.length(2); | ||
}); | ||
|
||
it('binds props.secondaryButton.label to first button label', () => { | ||
expect(wrapper.find('Button').at(0).props().label).to.equal(props.secondaryButton.label); | ||
}); | ||
|
||
it('binds props.primaryButton.label to second button label', () => { | ||
expect(wrapper.find('Button').at(1).props().label).to.equal(props.primaryButton.label); | ||
}); | ||
|
||
it('binds props.primaryButton.disabled to second button disabled', () => { | ||
expect(wrapper.find('Button').at(1).props().disabled).to.equal(props.primaryButton.disabled); | ||
}); | ||
|
||
it('binds props.secondaryButton.onClick to first button onClick', () => { | ||
wrapper.find('Button').at(0).simulate('click'); | ||
expect(props.secondaryButton.onClick).to.have.been.calledWith(); | ||
}); | ||
|
||
it('binds props.primaryButton.onClick to second button onClick', () => { | ||
wrapper.find('Button').at(1).simulate('click'); | ||
expect(props.primaryButton.onClick).to.have.been.calledWith(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the primary button disabled?nI was expecting it not to trigger the handler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not. See There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh sorry. yeah. :-D |
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove inline style