5 changed files with 79 additions and 134 deletions
@ -0,0 +1,60 @@ |
|||
import React from 'react' |
|||
import { shallow } from 'enzyme' |
|||
|
|||
import Form from '../../app/components/Form' |
|||
import PayForm from '../../app/components/Form/PayForm' |
|||
import RequestForm from '../../app/components/Form/RequestForm' |
|||
|
|||
const payFormProps = { |
|||
payform: {}, |
|||
currency: 'BTC', |
|||
crypto: 'BTC', |
|||
|
|||
isOnchain: false, |
|||
isLn: false, |
|||
currentAmount: '0', |
|||
inputCaption: '', |
|||
showPayLoadingScreen: false, |
|||
|
|||
setPayAmount: () => {}, |
|||
setPayInput: () => {}, |
|||
fetchInvoice: () => {}, |
|||
|
|||
|
|||
onPaySubmit: () => {} |
|||
} |
|||
|
|||
const requestFormProps = { |
|||
requestform: {}, |
|||
currency: '', |
|||
crypto: '', |
|||
|
|||
setRequestAmount: () => {}, |
|||
setRequestMemo: () => {}, |
|||
|
|||
onRequestSubmit: () => {} |
|||
} |
|||
|
|||
const defaultProps = { |
|||
formType: '', |
|||
formProps: {}, |
|||
closeForm: () => {} |
|||
} |
|||
|
|||
describe('Form', () => { |
|||
describe('should show pay form when formType is PAY_FORM', () => { |
|||
const props = { ...defaultProps, formType: 'PAY_FORM', formProps: payFormProps } |
|||
const el = shallow(<Form {...props} />) |
|||
it('should contain PayForm', () => { |
|||
expect(el.find(PayForm)).toHaveLength(1) |
|||
}) |
|||
}) |
|||
|
|||
describe('should show request form when formType is REQUEST_FORM', () => { |
|||
const props = { ...defaultProps, formType: 'REQUEST_FORM', formProps: requestFormProps } |
|||
const el = shallow(<Form {...props} />) |
|||
it('should contain RequestForm', () => { |
|||
expect(el.find(RequestForm)).toHaveLength(1) |
|||
}) |
|||
}) |
|||
}) |
@ -1,85 +1,7 @@ |
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
|||
|
|||
exports[`reducers formReducer should correctly resetForm 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "pay", |
|||
"message": "", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should correctly setAmount 1`] = ` |
|||
Object { |
|||
"amount": 1, |
|||
"formType": "pay", |
|||
"message": "", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should correctly setForm 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "foo", |
|||
"message": "", |
|||
"modalOpen": true, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should correctly setMessage 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "pay", |
|||
"message": "foo", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should correctly setPaymentRequest 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "pay", |
|||
"message": "", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "foo", |
|||
"pubkey": "", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should correctly setPubkey 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "pay", |
|||
"message": "", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "foo", |
|||
} |
|||
`; |
|||
|
|||
exports[`reducers formReducer should handle initial state 1`] = ` |
|||
Object { |
|||
"amount": "0", |
|||
"formType": "pay", |
|||
"message": "", |
|||
"modalOpen": false, |
|||
"onchainAmount": "0", |
|||
"payment_request": "", |
|||
"pubkey": "", |
|||
"formType": null, |
|||
} |
|||
`; |
|||
|
@ -1,64 +1,25 @@ |
|||
import formReducer, { |
|||
SET_FORM, |
|||
SET_AMOUNT, |
|||
SET_MESSAGE, |
|||
SET_PUBKEY, |
|||
SET_PAYMENT_REQUEST, |
|||
RESET_FORM |
|||
SET_FORM_TYPE |
|||
} from '../../app/reducers/form' |
|||
|
|||
// describe('reducers', () => {
|
|||
// describe('formReducer', () => {
|
|||
|
|||
// it('should have SET_FORM_TYPE', () => {
|
|||
// expect(SET_FORM_TYPE).toEqual('SET_FORM_TYPE')
|
|||
// })
|
|||
|
|||
// it('should correctly setFormType', () => {
|
|||
// expect(formReducer(undefined, { type: SET_FORM_TYPE, formType: 'FOO' })).toMatchSnapshot()
|
|||
// })
|
|||
// }
|
|||
// }
|
|||
|
|||
describe('reducers', () => { |
|||
describe('formReducer', () => { |
|||
it('should handle initial state', () => { |
|||
expect(formReducer(undefined, {})).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should have SET_FORM', () => { |
|||
expect(SET_FORM).toEqual('SET_FORM') |
|||
}) |
|||
|
|||
it('should have SET_AMOUNT', () => { |
|||
expect(SET_AMOUNT).toEqual('SET_AMOUNT') |
|||
}) |
|||
|
|||
it('should have SET_MESSAGE', () => { |
|||
expect(SET_MESSAGE).toEqual('SET_MESSAGE') |
|||
}) |
|||
|
|||
it('should have SET_PUBKEY', () => { |
|||
expect(SET_PUBKEY).toEqual('SET_PUBKEY') |
|||
}) |
|||
|
|||
it('should have SET_PAYMENT_REQUEST', () => { |
|||
expect(SET_PAYMENT_REQUEST).toEqual('SET_PAYMENT_REQUEST') |
|||
}) |
|||
|
|||
it('should have RESET_FORM', () => { |
|||
expect(RESET_FORM).toEqual('RESET_FORM') |
|||
}) |
|||
|
|||
it('should correctly setForm', () => { |
|||
expect(formReducer(undefined, { type: SET_FORM, modalOpen: true, formType: 'foo' })).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should correctly setAmount', () => { |
|||
expect(formReducer(undefined, { type: SET_AMOUNT, amount: 1 })).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should correctly setMessage', () => { |
|||
expect(formReducer(undefined, { type: SET_MESSAGE, message: 'foo' })).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should correctly setPubkey', () => { |
|||
expect(formReducer(undefined, { type: SET_PUBKEY, pubkey: 'foo' })).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should correctly setPaymentRequest', () => { |
|||
expect(formReducer(undefined, { type: SET_PAYMENT_REQUEST, payment_request: 'foo' })).toMatchSnapshot() |
|||
}) |
|||
|
|||
it('should correctly resetForm', () => { |
|||
expect(formReducer(undefined, { type: RESET_FORM })).toMatchSnapshot() |
|||
}) |
|||
}) |
|||
}) |
|||
|
Loading…
Reference in new issue