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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #534 from LiskHQ/516-click-to-send
Implement click to send functionality in React - Closes #516
- Loading branch information
Showing
10 changed files
with
158 additions
and
29 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { connect } from 'react-redux'; | ||
import { dialogDisplayed } from '../../actions/dialog'; | ||
import ClickToSendComponent from './clickToSendComponent'; | ||
|
||
|
||
const mapDispatchToProps = dispatch => ({ | ||
setActiveDialog: data => dispatch(dialogDisplayed(data)), | ||
}); | ||
|
||
const ClickToSend = connect( | ||
null, | ||
mapDispatchToProps, | ||
)(ClickToSendComponent); | ||
|
||
export default ClickToSend; |
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 { expect } from 'chai'; | ||
import { mount } from 'enzyme'; | ||
import { Provider } from 'react-redux'; | ||
import ClickToSend from './clickToSend'; | ||
import store from '../../store'; | ||
|
||
|
||
describe('Send Container', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Provider store={store}><ClickToSend /></Provider>); | ||
}); | ||
|
||
it('should render ClickToSendComponent', () => { | ||
expect(wrapper.find('ClickToSendComponent')).to.have.lengthOf(1); | ||
}); | ||
}); |
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,23 @@ | ||
import React from 'react'; | ||
import styles from './send.css'; | ||
import Send from '../send'; | ||
import { fromRawLsk } from '../../utils/lsk'; | ||
|
||
|
||
const ClickToSendComponent = props => ( | ||
props.disabled ? | ||
props.children : | ||
<span className={styles.clickable} | ||
onClick={() => (props.setActiveDialog({ | ||
title: 'Send', | ||
childComponent: Send, | ||
childComponentProps: { | ||
amount: props.rawAmount ? fromRawLsk(props.rawAmount) : props.amount, | ||
recipient: props.recipient, | ||
}, | ||
}))}> | ||
{props.children} | ||
</span> | ||
); | ||
|
||
export default ClickToSendComponent; |
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,46 @@ | ||
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 ClickToSendComponent from './clickToSendComponent'; | ||
|
||
const Dummy = () => (<span />); | ||
|
||
chai.use(sinonChai); | ||
chai.use(chaiEnzyme()); // Note the invocation at the end | ||
describe('ClickToSendComponent', () => { | ||
let setActiveDialog; | ||
|
||
beforeEach(() => { | ||
setActiveDialog = sinon.spy(); | ||
}); | ||
|
||
it('allows open send modal with prefilled address ', () => { | ||
const wrapper = mount( | ||
<ClickToSendComponent address='16313739661670634666L' | ||
setActiveDialog={setActiveDialog}><Dummy /></ClickToSendComponent>); | ||
wrapper.simulate('click'); | ||
expect(setActiveDialog).to.have.been.calledWith(); | ||
expect(wrapper.find('Dummy')).to.have.length(1); | ||
}); | ||
|
||
it('allows open send modal with prefilled rawAmount ', () => { | ||
const wrapper = mount( | ||
<ClickToSendComponent rawAmount='100000000' | ||
setActiveDialog={setActiveDialog}><Dummy /></ClickToSendComponent>); | ||
wrapper.simulate('click'); | ||
expect(setActiveDialog).to.have.been.calledWith(); | ||
expect(wrapper.find('Dummy')).to.have.length(1); | ||
}); | ||
|
||
it('should do nothing if props.disabled', () => { | ||
const wrapper = mount( | ||
<ClickToSendComponent disabled={true} | ||
setActiveDialog={setActiveDialog}><Dummy /> | ||
</ClickToSendComponent>); | ||
wrapper.simulate('click'); | ||
expect(wrapper.find('Dummy')).to.have.length(1); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -15,3 +15,7 @@ | |
line-height: 14px; | ||
color: grey; | ||
} | ||
|
||
.clickable { | ||
cursor: pointer; | ||
} |
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