Browse Source
Form.spec just shallow renders the Form, so PayForm and RequestForm were previously only tested insofar as their props were valiated by propTypes. Testing them directly means the form is rendered.renovate/lint-staged-8.x
Ben Woosley
7 years ago
5 changed files with 91 additions and 5 deletions
@ -0,0 +1,41 @@ |
|||||
|
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) |
||||
|
}) |
||||
|
}) |
||||
|
}) |
@ -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…
Reference in new issue