Browse Source

Merge pull request #165 from Empact/enhance/form-tests

Add some further testing to the PayForm and RequestForm
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
0c0596fcf1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      app/components/Form/PayForm.js
  2. 5
      app/components/Form/RequestForm.js
  3. 11
      test/components/Form.spec.js
  4. 63
      test/components/Form/Payform.spec.js
  5. 28
      test/components/Form/RequestForm.spec.js

11
app/components/Form/PayForm.js

@ -119,7 +119,11 @@ class PayForm extends Component {
PayForm.propTypes = {
payform: PropTypes.object.isRequired,
payform: PropTypes.shape({
amount: PropTypes.string.isRequired,
payInput: PropTypes.string.isRequired,
showErrors: PropTypes.object.isRequired
}).isRequired,
currency: PropTypes.string.isRequired,
crypto: PropTypes.string.isRequired,
@ -131,7 +135,10 @@ PayForm.propTypes = {
]).isRequired,
inputCaption: PropTypes.string.isRequired,
showPayLoadingScreen: PropTypes.bool.isRequired,
payFormIsValid: PropTypes.object.isRequired,
payFormIsValid: PropTypes.shape({
errors: PropTypes.object,
isValid: PropTypes.bool
}).isRequired,
setPayAmount: PropTypes.func.isRequired,
onPayAmountBlur: PropTypes.func.isRequired,

5
app/components/Form/RequestForm.js

@ -48,7 +48,10 @@ const RequestForm = ({
)
RequestForm.propTypes = {
requestform: PropTypes.object.isRequired,
requestform: PropTypes.shape({
amount: PropTypes.string.isRequired,
memo: PropTypes.string
}).isRequired,
currency: PropTypes.string.isRequired,
crypto: PropTypes.string.isRequired,

11
test/components/Form.spec.js

@ -6,7 +6,11 @@ import PayForm from '../../app/components/Form/PayForm'
import RequestForm from '../../app/components/Form/RequestForm'
const payFormProps = {
payform: {},
payform: {
amount: '',
payInput: '',
showErrors: {}
},
currency: 'BTC',
crypto: 'BTC',
@ -28,7 +32,10 @@ const payFormProps = {
}
const requestFormProps = {
requestform: {},
requestform: {
amount: '',
memo: ''
},
currency: '',
crypto: '',

63
test/components/Form/Payform.spec.js

@ -0,0 +1,63 @@
import React from 'react'
import { shallow } from 'enzyme'
import PayForm from '../../../app/components/Form/PayForm'
const defaultProps = {
payform: {
amount: '',
payInput: '',
showErrors: {}
},
currency: 'BTC',
crypto: 'BTC',
isOnchain: false,
isLn: false,
currentAmount: '0',
inputCaption: '',
showPayLoadingScreen: false,
payFormIsValid: {},
setPayAmount: () => {},
onPayAmountBlur: () => {},
setPayInput: () => {},
onPayInputBlur: () => {},
fetchInvoice: () => {},
onPaySubmit: () => {}
}
describe('Form', () => {
describe('should show the form without an input', () => {
const el = shallow(<PayForm {...defaultProps} />)
it('should contain PayForm', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(false)
expect(el.contains('on-chain')).toBe(false)
})
})
describe('should show lightning with a lightning input', () => {
const props = { ...defaultProps, isLn: true }
const el = shallow(<PayForm {...props} />)
it('should contain PayForm', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(true)
expect(el.contains('on-chain')).toBe(false)
})
})
describe('should show on-chain with an on-chain input', () => {
const props = { ...defaultProps, isOnchain: true }
const el = shallow(<PayForm {...props} />)
it('should contain PayForm', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(false)
expect(el.contains('on-chain')).toBe(true)
})
})
})

28
test/components/Form/RequestForm.spec.js

@ -0,0 +1,28 @@
import React from 'react'
import { shallow } from 'enzyme'
import RequestForm from '../../../app/components/Form/RequestForm'
const defaultProps = {
requestform: {
amount: '',
showErrors: {}
},
currency: '',
crypto: '',
setRequestAmount: () => {},
setRequestMemo: () => {},
onRequestSubmit: () => {}
}
describe('Form', () => {
describe('should show request form when formType is REQUEST_FORM', () => {
const props = { ...defaultProps }
const el = shallow(<RequestForm {...props} />)
it('should contain RequestForm', () => {
expect(el.contains('Request')).toBe(true)
})
})
})
Loading…
Cancel
Save