Skip to content

Commit

Permalink
fix(Coinify): change error check and include error msg for other errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Welber authored and plondon committed Sep 21, 2018
1 parent 24dbb23 commit 4e83280
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
@@ -0,0 +1,45 @@
import React from 'react'
import { TestBed, getDispatchSpyReducer, createTestStore } from 'utils/testbed'
import { mount } from 'enzyme'
import { combineReducers } from 'redux'

// import { actions } from 'data'
import { coreReducers, paths } from 'blockchain-wallet-v4/src'
import modalsReducer from 'data/modals/reducers'

import AcceptTerms from './index'

const { dispatchSpy, spyReducer } = getDispatchSpyReducer()

describe('Coinify AcceptTerms Modal', () => {
beforeEach(() => {
dispatchSpy.mockClear()
})
const reducers = {
spy: spyReducer,
modals: modalsReducer,
components: combineReducers({}),
[paths.settingsPath]: coreReducers.settings
}
let store
let wrapper
beforeEach(() => {
store = createTestStore(reducers)
wrapper = mount(
<TestBed store={store}>
<AcceptTerms />
</TestBed>
)
})

describe('modal rendering', () => {
it('should render', () => {
expect(wrapper.find('Field[name="terms"]')).toHaveLength(1)
})

it('should should be disabled with terms not clicked', () => {
expect(wrapper.find('Field[name="terms"]').find('input').props().checked).toBe(false)
expect(wrapper.find('button').props().disabled).toBe(true)
})
})
})
Expand Up @@ -29,6 +29,8 @@ import {
import { prop } from 'ramda'
import media from 'services/ResponsiveService'

export const EMAIL_IN_USE_ERROR = 'email_address_and_partner_id_in_use'

const AcceptTermsContainer = styled.div`
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -200,8 +202,7 @@ const AcceptTerms = props => {
</Button>
</ButtonWrapper>
<ErrorWrapper>
{signupError &&
prop('error', signupError) === 'email_address_in_use' ? (
{signupError && prop('error', signupError) === EMAIL_IN_USE_ERROR ? (
<TextGroup inline>
<Text size='12px' color='error' weight={300}>
<FormattedMessage
Expand Down Expand Up @@ -253,6 +254,14 @@ const AcceptTerms = props => {
defaultMessage='contact support.'
/>
</Link>
<br />
<Text size='12px' color='error' weight={300}>
<FormattedMessage
id='coinifyexchangedata.create.accept.support_error_description'
defaultMessage='Error Description: {errorDescription}'
values={{ errorDescription: prop('error_description', signupError) }}
/>
</Text>
</TextGroup>
) : null}
</ErrorWrapper>
Expand Down

0 comments on commit 4e83280

Please sign in to comment.