diff --git a/test/components/Channels.spec.js b/test/components/Channels.spec.js index 3df31617..9b8019ee 100644 --- a/test/components/Channels.spec.js +++ b/test/components/Channels.spec.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React from 'react' import { shallow } from 'enzyme' import Channels from '../../app/components/Channels' diff --git a/test/components/Form.spec.js b/test/components/Form.spec.js new file mode 100644 index 00000000..3024a3b4 --- /dev/null +++ b/test/components/Form.spec.js @@ -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(
) + 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() + it('should contain RequestForm', () => { + expect(el.find(RequestForm)).toHaveLength(1) + }) + }) +}) diff --git a/test/reducers/__snapshots__/form.spec.js.snap b/test/reducers/__snapshots__/form.spec.js.snap index c4351236..0d064828 100644 --- a/test/reducers/__snapshots__/form.spec.js.snap +++ b/test/reducers/__snapshots__/form.spec.js.snap @@ -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, } `; diff --git a/test/reducers/__snapshots__/invoice.spec.js.snap b/test/reducers/__snapshots__/invoice.spec.js.snap index 728904d0..c2d59f50 100644 --- a/test/reducers/__snapshots__/invoice.spec.js.snap +++ b/test/reducers/__snapshots__/invoice.spec.js.snap @@ -66,7 +66,9 @@ exports[`reducers invoiceReducer should correctly receiveFormInvoice 1`] = ` Object { "data": Object {}, "formInvoice": Object { - "payreq": "foo", + "amount": "0", + "payreq": "", + "r_hash": "", }, "invoice": null, "invoiceLoading": false, diff --git a/test/reducers/form.spec.js b/test/reducers/form.spec.js index 5f401b48..13540f69 100644 --- a/test/reducers/form.spec.js +++ b/test/reducers/form.spec.js @@ -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() - }) }) })