diff --git a/test/reducers/__snapshots__/form.spec.js.snap b/test/reducers/__snapshots__/form.spec.js.snap new file mode 100644 index 00000000..8e69e1db --- /dev/null +++ b/test/reducers/__snapshots__/form.spec.js.snap @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`reducers formReducer should correctly resetForm 1`] = ` +Object { + "amount": "0", + "formType": "pay", + "message": "", + "modalOpen": false, + "payment_request": "", + "pubkey": "", +} +`; + +exports[`reducers formReducer should correctly setAmount 1`] = ` +Object { + "amount": 1, + "formType": "pay", + "message": "", + "modalOpen": false, + "payment_request": "", + "pubkey": "", +} +`; + +exports[`reducers formReducer should correctly setForm 1`] = ` +Object { + "amount": "0", + "formType": "foo", + "message": "", + "modalOpen": true, + "payment_request": "", + "pubkey": "", +} +`; + +exports[`reducers formReducer should correctly setMessage 1`] = ` +Object { + "amount": "0", + "formType": "pay", + "message": "foo", + "modalOpen": false, + "payment_request": "", + "pubkey": "", +} +`; + +exports[`reducers formReducer should correctly setPaymentRequest 1`] = ` +Object { + "amount": "0", + "formType": "pay", + "message": "", + "modalOpen": false, + "payment_request": "foo", + "pubkey": "", +} +`; + +exports[`reducers formReducer should correctly setPubkey 1`] = ` +Object { + "amount": "0", + "formType": "pay", + "message": "", + "modalOpen": false, + "payment_request": "", + "pubkey": "foo", +} +`; + +exports[`reducers formReducer should handle initial state 1`] = ` +Object { + "amount": "0", + "formType": "pay", + "message": "", + "modalOpen": false, + "payment_request": "", + "pubkey": "", +} +`; diff --git a/test/reducers/form.spec.js b/test/reducers/form.spec.js new file mode 100644 index 00000000..e547024c --- /dev/null +++ b/test/reducers/form.spec.js @@ -0,0 +1,64 @@ +import formReducer, { + SET_FORM, + SET_AMOUNT, + SET_MESSAGE, + SET_PUBKEY, + SET_PAYMENT_REQUEST, + RESET_FORM +} from '../../app/reducers/form' + +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() + }) + }) +}) \ No newline at end of file